Skip to content

Commit

Permalink
Merge dev-2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienlauer committed Sep 27, 2016
2 parents 3d75210 + 68d8c59 commit f4639be
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cache:

install:
- echo "<settings><servers><server><id>bintray</id><username>\${env.BINTRAY_USER}</username><password>\${env.BINTRAY_KEY}</password></server></servers></settings>" > ~/.m2/settings.xml
- if [[ $TRAVIS_PULL_REQUEST = false ]] && [[ $TRAVIS_BRANCH = master ]] || [[ $TRAVIS_TAG = v* ]]; then GOAL=deploy; else GOAL=install; fi
- if [[ $TRAVIS_PULL_REQUEST = false ]] && [[ $TRAVIS_BRANCH = master || $TRAVIS_BRANCH = dev-* ]] || [[ $TRAVIS_TAG = v* ]]; then GOAL=deploy; else GOAL=install; fi
- if [[ $TRAVIS_TAG = v* ]]; then ADDITIONAL_PROFILES=release; mvn -q -U org.seedstack:seedstack-maven-plugin:release; else ADDITIONAL_PROFILES=snapshots; fi

script: mvn -q -U -T 2 -Pbuild-number,compatibility,bintray,javadoc,$ADDITIONAL_PROFILES $GOAL jacoco:report
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 2.2.1.1 (2016-09-27)

* [chg] Made JMS request message id, reply message id and correlation id accessible through the response context.

# Version 2.2.2 (2016-04-26)

* [chg] Update for SeedStack 16.4.
Expand Down
14 changes: 14 additions & 0 deletions jms/src/it/java/org/seedstack/ws/WSJmsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
import org.junit.runner.RunWith;
import org.seedstack.seed.Configuration;
import org.seedstack.seed.it.SeedITRunner;
import org.seedstack.ws.jms.internal.JmsConstants;
import org.seedstack.ws.jms.internal.JmsTransportException;
import org.seedstack.wsdl.seed.calculator.CalculatorService;
import org.seedstack.wsdl.seed.calculator.CalculatorWS;

import javax.xml.ws.BindingProvider;
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
Expand Down Expand Up @@ -162,4 +164,16 @@ public void using_text_message() {
((BindingProvider) calculatorWS).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "jms:jndi:dynamicQueues/TEST.QUEUE?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&jndiConnectionFactoryName=ConnectionFactory&jndiURL=vm://localhost?broker.persistent=false&deliveryMode=NON_PERSISTENT&messageType=text");
assertThat(calculatorWS.add(1, 1)).isEqualTo(2);
}

@Test
public void message_identifiers_are_accessible() {
CalculatorService calculatorService = new CalculatorService();
CalculatorWS calculatorWS = calculatorService.getCalculatorSoapJmsPort();
((BindingProvider) calculatorWS).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "jms:jndi:dynamicQueues/TEST.QUEUE?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory&jndiConnectionFactoryName=ConnectionFactory&jndiURL=vm://localhost?broker.persistent=false&deliveryMode=NON_PERSISTENT&messageType=text");
assertThat(calculatorWS.add(1, 1)).isEqualTo(2);
Map<String, Object> responseContext = ((BindingProvider) calculatorWS).getResponseContext();
assertThat(((String) responseContext.get(JmsConstants.JMS_REQUEST_MESSAGE_ID))).isNotEmpty();
assertThat(((String) responseContext.get(JmsConstants.JMS_REPLY_MESSAGE_ID))).isNotEmpty();
assertThat(((String) responseContext.get(JmsConstants.JMS_CORRELATION_ID))).isNotEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class JmsClientTransport {
private final LoadingCache<SoapJmsUri, Connection> connectionCache;
private final Packet packet;
private final Map<String, String> requestHeaders;
private String requestMessageId;
private String replyMessageId;
private String correlationId;
private Message replyMessage;

@Inject
Expand Down Expand Up @@ -117,7 +120,7 @@ byte[] sendMessage(byte[] sndPacket) {
}

if (packet.expectReply) {
String correlationId = UUID.randomUUID().toString();
correlationId = UUID.randomUUID().toString();
Destination replyDestination = SoapJmsUri.getReplyToDestination(destinationAddress, session);

if (replyDestination == null) {
Expand All @@ -137,6 +140,7 @@ byte[] sendMessage(byte[] sndPacket) {
}

producer.send(message);
requestMessageId = message.getJMSMessageID();
producer.close();
} catch (Exception e) {
throw new JmsTransportException("Error sending JMS message", e);
Expand All @@ -145,6 +149,7 @@ byte[] sendMessage(byte[] sndPacket) {
if (messageConsumer != null) {
try {
replyMessage = messageConsumer.receive(responseTimeout);
replyMessageId = replyMessage.getJMSMessageID();

if (replyMessage instanceof BytesMessage) {
BytesMessage bytesReplyMessage = (BytesMessage) replyMessage;
Expand Down Expand Up @@ -203,4 +208,16 @@ String getResponseContentType() {
throw new WebServiceException("No response available");
}
}

String getRequestMessageId() {
return requestMessageId;
}

String getReplyMessageId() {
return replyMessageId;
}

String getCorrelationId() {
return correlationId;
}
}
23 changes: 14 additions & 9 deletions jms/src/main/java/org/seedstack/ws/jms/internal/JmsConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@
*/
package org.seedstack.ws.jms.internal;

final class JmsConstants {
public final class JmsConstants {
private JmsConstants() {
// hide default constructor
}

static final String REQUEST_URI = "SOAPJMS_requestURI";
static final String BINDING_VERSION = "SOAPJMS_bindingVersion";
static final String SOAP_ACTION = "SOAPJMS_soapAction";
static final String TARGET_SERVICE = "SOAPJMS_targetService";
static final String CONTENT_TYPE_PROPERTY = "SOAPJMS_contentType";
static final String ENCODING_PROPERTY = "SOAPJMS_contentEncoding";
static final String IS_FAULT = "SOAPJMS_isFault";
// JMS headers
public static final String REQUEST_URI = "SOAPJMS_requestURI";
public static final String BINDING_VERSION = "SOAPJMS_bindingVersion";
public static final String SOAP_ACTION = "SOAPJMS_soapAction";
public static final String TARGET_SERVICE = "SOAPJMS_targetService";
public static final String CONTENT_TYPE_PROPERTY = "SOAPJMS_contentType";
public static final String ENCODING_PROPERTY = "SOAPJMS_contentEncoding";
public static final String IS_FAULT = "SOAPJMS_isFault";

static final String JMS_REQUEST_HEADERS = "JMS-RQ-Headers";
// Constants used in BindingProvider#getRequestContext() and/or BindingProvider#getResponseContext()
public static final String JMS_REQUEST_HEADERS = "JMS-RQ-Headers";
public static final String JMS_REQUEST_MESSAGE_ID = "JMS-RQ-MessageId";
public static final String JMS_REPLY_MESSAGE_ID = "JMS-RP-MessageId";
public static final String JMS_CORRELATION_ID = "JMS-CorrelationId";
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ public NextAction processRequest(Packet request) {
replyPacketInStream = new ByteArrayInputStream(rplPacket);
codec.decode(replyPacketInStream, contentTypeStr, reply);

// Put JMS identifiers in invocation properties for later access in business code
String requestMessageId = con.getRequestMessageId();
if (requestMessageId != null) {
reply.invocationProperties.put(JmsConstants.JMS_REQUEST_MESSAGE_ID, requestMessageId);
}
String replyMessageId = con.getReplyMessageId();
if (replyMessageId != null) {
reply.invocationProperties.put(JmsConstants.JMS_REPLY_MESSAGE_ID, replyMessageId);
}
String correlationId = con.getCorrelationId();
if (correlationId != null) {
reply.invocationProperties.put(JmsConstants.JMS_CORRELATION_ID, correlationId);
}

return doReturnWith(reply);
} catch (WebServiceException wex) {
throw wex;
Expand Down

0 comments on commit f4639be

Please sign in to comment.