Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATAGO-84854: Use ProducerFlowProperties constructor that supports full session pass-through #340

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

<dependency>
<groupId>com.solacesystems</groupId>
<artifactId>sol-jms</artifactId>
<artifactId>sol-jms-jakarta</artifactId>
<version>${solace.jms.version}</version>
<scope>test</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.solacesystems.jcsmp.Destination;
import com.solacesystems.jcsmp.JCSMPException;
import com.solacesystems.jcsmp.JCSMPFactory;
import com.solacesystems.jcsmp.JCSMPProperties;
import com.solacesystems.jcsmp.JCSMPSession;
import com.solacesystems.jcsmp.JCSMPStreamingPublishCorrelatingEventHandler;
import com.solacesystems.jcsmp.Topic;
Expand Down Expand Up @@ -48,6 +49,7 @@ public class JCSMPOutboundMessageHandler implements MessageHandler, Lifecycle {
private final DestinationType configDestinationType;
private final Destination configDestination;
private final JCSMPSession jcsmpSession;
private final JCSMPProperties jcsmpProperties;
private final MessageChannel errorChannel;
private final JCSMPSessionProducerManager producerManager;
private final ExtendedProducerProperties<SolaceProducerProperties> properties;
Expand All @@ -63,6 +65,7 @@ public class JCSMPOutboundMessageHandler implements MessageHandler, Lifecycle {

public JCSMPOutboundMessageHandler(ProducerDestination destination,
JCSMPSession jcsmpSession,
JCSMPProperties jcsmpProperties,
MessageChannel errorChannel,
JCSMPSessionProducerManager producerManager,
ExtendedProducerProperties<SolaceProducerProperties> properties,
Expand All @@ -72,6 +75,7 @@ public JCSMPOutboundMessageHandler(ProducerDestination destination,
JCSMPFactory.onlyInstance().createTopic(destination.getName()) :
JCSMPFactory.onlyInstance().createQueue(destination.getName());
this.jcsmpSession = jcsmpSession;
this.jcsmpProperties = jcsmpProperties;
this.errorChannel = errorChannel;
this.producerManager = producerManager;
this.properties = properties;
Expand Down Expand Up @@ -239,10 +243,10 @@ public void start() {
if (properties.getExtension().isTransacted()) {
LOGGER.info("Creating transacted session <message handler ID: {}>", id);
transactedSession = jcsmpSession.createTransactedSession();
producer = transactedSession.createProducer(SolaceProvisioningUtil.getProducerFlowProperties(jcsmpSession),
producer = transactedSession.createProducer(SolaceProvisioningUtil.getProducerFlowProperties(jcsmpProperties),
producerEventHandler);
} else {
producer = jcsmpSession.createProducer(SolaceProvisioningUtil.getProducerFlowProperties(jcsmpSession),
producer = jcsmpSession.createProducer(SolaceProvisioningUtil.getProducerFlowProperties(jcsmpProperties),
producerEventHandler);
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.solacesystems.jcsmp.EndpointProperties;
import com.solacesystems.jcsmp.JCSMPFactory;
import com.solacesystems.jcsmp.JCSMPProperties;
import com.solacesystems.jcsmp.JCSMPSession;
import com.solacesystems.jcsmp.ProducerFlowProperties;
import org.springframework.cloud.stream.binder.ExtendedConsumerProperties;
import org.springframework.cloud.stream.binder.ExtendedProducerProperties;
Expand Down Expand Up @@ -51,22 +50,8 @@ public static EndpointProperties getErrorQueueEndpointProperties(SolaceConsumerP
return endpointProperties;
}

public static ProducerFlowProperties getProducerFlowProperties(JCSMPSession jcsmpSession) {
ProducerFlowProperties producerFlowProperties = new ProducerFlowProperties();

// SOL-118898:
// PUB_ACK_WINDOW_SIZE & ACK_EVENT_MODE aren't automatically used as default values for
// ProducerFlowProperties.
Integer pubAckWindowSize = (Integer) jcsmpSession.getProperty(JCSMPProperties.PUB_ACK_WINDOW_SIZE);
if (pubAckWindowSize != null) {
producerFlowProperties.setWindowSize(pubAckWindowSize);
}
String ackEventMode = (String) jcsmpSession.getProperty(JCSMPProperties.ACK_EVENT_MODE);
if (ackEventMode != null) {
producerFlowProperties.setAckEventMode(ackEventMode);
}

return producerFlowProperties;
public static ProducerFlowProperties getProducerFlowProperties(JCSMPProperties jcsmpProperties) {
return new ProducerFlowProperties(jcsmpProperties);
}

public static ConsumerFlowProperties getConsumerFlowProperties(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class JCSMPOutboundMessageHandlerTest {
private ArgumentCaptor<ProducerFlowProperties> producerFlowPropertiesCaptor;
private ExtendedProducerProperties<SolaceProducerProperties> producerProperties;
private JCSMPSessionProducerManager sessionProducerManager;
@Mock private JCSMPProperties jcsmpProperties;
@Mock private JCSMPSession session;
@Mock private TransactedSession transactedSession;
@Mock private XMLMessageProducer messageProducer;
Expand Down Expand Up @@ -105,6 +106,7 @@ public void init(@Mock MessageChannel errChannel,
messageHandler = new JCSMPOutboundMessageHandler(
dest,
session,
jcsmpProperties,
errChannel,
sessionProducerManager,
producerProperties,
Expand Down Expand Up @@ -500,6 +502,7 @@ public void test_dynamic_destinationName_with_destinationType_configured_on_mess
messageHandler = new JCSMPOutboundMessageHandler(
dest,
session,
jcsmpProperties,
null,
new JCSMPSessionProducerManager(session),
new ExtendedProducerProperties<>(producerProperties),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.util.SerializationUtils;

import javax.jms.Connection;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.ObjectMessage;
import javax.jms.Session;
import java.util.ArrayList;
import java.util.Base64;
import java.util.Enumeration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.solacesystems.jcsmp.Context;
import com.solacesystems.jcsmp.Endpoint;
import com.solacesystems.jcsmp.EndpointProperties;
import com.solacesystems.jcsmp.JCSMPProperties;
import com.solacesystems.jcsmp.JCSMPSession;
import com.solacesystems.jcsmp.Queue;
import com.solacesystems.jcsmp.XMLMessage;
Expand Down Expand Up @@ -52,6 +53,7 @@ public class SolaceMessageChannelBinder
DisposableBean {

private final JCSMPSession jcsmpSession;
private final JCSMPProperties jcsmpProperties;
private final Context jcsmpContext;
private final JCSMPSessionProducerManager sessionProducerManager;
private final AtomicBoolean consumersRemoteStopFlag = new AtomicBoolean(false);
Expand All @@ -61,12 +63,13 @@ public class SolaceMessageChannelBinder
private static final SolaceMessageHeaderErrorMessageStrategy errorMessageStrategy = new SolaceMessageHeaderErrorMessageStrategy();
@Nullable private SolaceBinderHealthAccessor solaceBinderHealthAccessor;

public SolaceMessageChannelBinder(JCSMPSession jcsmpSession, SolaceEndpointProvisioner solaceEndpointProvisioner) {
this(jcsmpSession, null, solaceEndpointProvisioner);
public SolaceMessageChannelBinder(JCSMPSession jcsmpSession, JCSMPProperties jcsmpProperties, SolaceEndpointProvisioner solaceEndpointProvisioner) {
this(jcsmpSession, jcsmpProperties, null, solaceEndpointProvisioner);
}
public SolaceMessageChannelBinder(JCSMPSession jcsmpSession, Context jcsmpContext, SolaceEndpointProvisioner solaceEndpointProvisioner) {
public SolaceMessageChannelBinder(JCSMPSession jcsmpSession, JCSMPProperties jcsmpProperties, Context jcsmpContext, SolaceEndpointProvisioner solaceEndpointProvisioner) {
super(new String[0], solaceEndpointProvisioner);
this.jcsmpSession = jcsmpSession;
this.jcsmpProperties = jcsmpProperties;
this.jcsmpContext = jcsmpContext;
this.sessionProducerManager = new JCSMPSessionProducerManager(jcsmpSession);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private void initSession() throws JCSMPException {
SolaceMessageChannelBinder solaceMessageChannelBinder(SolaceEndpointProvisioner solaceEndpointProvisioner,
@Nullable SolaceBinderHealthAccessor solaceBinderHealthAccessor,
@Nullable SolaceMeterAccessor solaceMeterAccessor) {
SolaceMessageChannelBinder binder = new SolaceMessageChannelBinder(jcsmpSession, context, solaceEndpointProvisioner);
SolaceMessageChannelBinder binder = new SolaceMessageChannelBinder(jcsmpSession, jcsmpProperties, context, solaceEndpointProvisioner);
binder.setExtendedBindingProperties(solaceExtendedBindingProperties);
binder.setSolaceMeterAccessor(solaceMeterAccessor);
if (solaceBinderHealthAccessor != null) {
Expand Down
Loading