Sending message with Spring Integration and ActiveMQ Artemis queue - spring-integration

I'm trying to send messages from a Spring Boot application using ActiveMQ Artemis and Spring Integration. In the management console I can see the address and the queue with 7 routed message count, but message count is 0 and consumers are not getting the messages:
In my producer I'm using JMS outbound adapter to send messages:
#Bean
public IntegrationFlow outboundFlow(ActiveMQConnectionFactory connectionFactory) {
return IntegrationFlows
.from(requests())
.transform(messageConverterQueue())
.log()
.handle(Jms.outboundAdapter(connectionFactory).destination(new ActiveMQQueue("requests")))
.get();
}
In the logs I can see the GenericMessage with payload and header with no errors from the broker.
For the consumer:
#Bean
public IntegrationFlow inboundFlowW(ActiveMQConnectionFactory connectionFactory) throws Exception {
return IntegrationFlows
.from(Jms.messageDrivenChannelAdapter(connectionFactory).destination("requests"))
.transform(jsonToChunkRequestTransformer)
.handle(chunkProcessorChunkHandler())
.channel(replies())
.get();
}
Previously I forgot to launch the consumer that's why consumer count is 0 but when it's running it turned 1.
Here is the trace:
DEBUG 19268 --- [erContainer#0-1] o.a.a.a.c.p.core.impl.ChannelImpl : RemotingConnectionID=48a825d5 Sending packet nonblocking PACKET(SessionForceConsumerDelivery)[type=78, channelID=11, responseAsync=false, requiresResponse=false, correlationID=-1, packetObject=SessionForceConsumerDelivery, consumerID=0, sequence=14] on channelID=11
DEBUG 19268 --- [erContainer#0-1] o.a.a.a.c.p.core.impl.ChannelImpl : RemotingConnectionID=48a825d5 Writing buffer for channelID=11
INFO 19268 --- [global-threads)] o.s.integration.handler.LoggingHandler : GenericMessage [payload={"jobId":348,...}, headers={id=c69469bd-8c5a-131f-ef61-cf6d86b308ca, json_resolvableType=org.springframework.batch.integration.chunk.ChunkRequest<?>, json__TypeId__=class org.springframework.batch.integration.chunk.ChunkRequest, contentType=application/json, timestamp=1635790793335}]
DEBUG 19268 --- [global-threads)] o.a.a.a.c.p.core.impl.ChannelImpl : RemotingConnectionID=1362aceb Sending blocking PACKET(SessionBindingQueryMessage)[type=49, channelID=11, responseAsync=false, requiresResponse=false, correlationID=-1, packetObject=SessionBindingQueryMessage, address=requests]
DEBUG 19268 --- [-netty-threads)] o.a.a.a.c.p.c.i.RemotingConnectionImpl : RemotingConnectionID=48a825d5 handling packet PACKET(SessionReceiveMessage)[type=75, channelID=11, responseAsync=false, requiresResponse=false, correlationID=-1, packetObject=SessionReceiveMessage, message=ClientMessageImpl[messageID=253545, durable=false, address=replies,userID=null,properties=TypedProperties[_hornetq.forced.delivery.seq=14]], consumerID=0, deliveryCount=0]
DEBUG 19268 --- [erContainer#0-1] o.a.a.a.c.c.impl.ClientConsumerImpl : org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl#5d2e71f5{consumerContext=ActiveMQConsumerContext{id=0}, queueName=replies}::There was nothing on the queue, leaving it now:: returning null
DEBUG 19268 --- [erContainer#0-1] o.a.a.a.c.c.impl.ClientConsumerImpl : org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl#5d2e71f5{consumerContext=ActiveMQConsumerContext{id=0}, queueName=replies}:: returning null
TRACE 19268 --- [erContainer#0-1] o.s.j.l.DefaultMessageListenerContainer : Consumer [ActiveMQMessageConsumer[org.apache.activemq.artemis.core.client.impl.ClientConsumerImpl#5d2e71f5{consumerContext=ActiveMQConsumerContext{id=0}, queueName=replies}]] of session [ActiveMQSession->ClientSessionImpl [name=41d6e210-3b40-11ec-84ef-00ff1cbc4657, username=artemis, closed=false, factory = org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryImpl#2d41bb5a, metaData=(jms-session=,)]#97a3bf2] did not receive a message
DEBUG 19268 --- [erContainer#0-1] o.a.a.a.c.client.impl.ClientSessionImpl : Sending commit
Can anyone tell me what happened to the messages? Why they're missing in the queue?

Related

Why i keep getting Message Rejected from AMQP?

I have an app on Quarkus that is receiving AmqpMessages, and send them to another topic.
I keep get an error from smallrye saying that the message was rejected.
Here are the properties
mp.messaging.incoming.data.address=incoming
mp.messaging.incoming.data.connector=smallrye-amqp
mp.messaging.incoming.data.host=localhost
mp.messaging.incoming.data.port=5672
mp.messaging.incoming.data.broadcast=true
mp.messaging.incoming.data.durable=false
mp.messaging.outgoing.position.address=outgoing
mp.messaging.outgoing.position.connector=smallrye-amqp
mp.messaging.outgoing.position.host=localhost
mp.messaging.outgoing.position.port=5672
mp.messaging.outgoing.position.durable=false
The class itself
#Incoming("data")
#Outgoing("position")
public CompletionStage handleMessage(final String topic, final MessagingMessage messageToProcess) {
final String message = messageToProcess.getMessageString();
final String tenant = messageToProcess.getTenant();
final String Id = messageToProcess.Id();
final Message message = _gson.fromJson(message, Message.class);
return _service.getStuff(tenant, id)
.thenApply(stuff -> calculate(message, thing))
.thenApply(Data -> buildAmqpMessage(tenant, id, message, Data))
.exceptionally(ex -> {
_logger.errorv("Error handling message: {0} ", ex);
return null;
});
}
public AmqpMessage buildAmqpMessage(final String tenant, final String id,
final Message message, final Data data) {
final OpenMessage messageToSend = buildMessage(message, openClosePercentageData);
return OutgoingAmqpMessage.builder()
.withSubject(_gson.toJson(messageToSend))
.build();
}
The logs output:
2020-05-10 20:35:36,376 DEBUG [io.sma.rea.mes.amq.AmqpConnector] (vert.x-eventloop-thread-1) Sending AMQP message to address `outgoing`
2020-05-10 20:35:36,377 FINEST [io.ver.pro.imp.ProtonTransport] (vert.x-eventloop-thread-1) New Proton Event: LINK_FLOW
2020-05-10 20:35:36,523 FINE [pro.trace] (vert.x-eventloop-thread-1) IN: CH[0] : Flow{nextIncomingId=2, incomingWindow=2147483647, nextOutgoingId=0, outgoingWindow=2147483647, handle=0, deliveryCount=1, linkCredit=250, available=null, drain=false, echo=false, properties=null}
2020-05-10 20:35:36,523 FINE [pro.trace] (vert.x-eventloop-thread-1) IN: CH[0] : Disposition{role=RECEIVER, first=0, last=null, settled=true, state=Rejected{error=Error{condition=amqp:not-found, description='Deliveries cannot be sent to an unavailable address', info=null}}, batchable=false}
2020-05-10 20:35:36,523 FINEST [io.ver.pro.imp.ProtonTransport] (vert.x-eventloop-thread-1) New Proton Event: LINK_FLOW
2020-05-10 20:35:36,523 FINEST [io.ver.pro.imp.ProtonTransport] (vert.x-eventloop-thread-1) New Proton Event: DELIVERY
2020-05-10 20:35:36,524 ERROR [io.sma.rea.mes.amq.AmqpConnector] (vert.x-eventloop-thread-1) Unable to send the AMQP message: java.util.concurrent.CompletionException: io.vertx.core.impl.NoStackTraceThrowable: message rejected (REJECTED
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:331)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:346)
at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1137)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2159)
at io.vertx.axle.AsyncResultCompletionStage.lambda$toCompletionStage$0(AsyncResultCompletionStage.java:20)
at io.vertx.amqp.impl.AmqpSenderImpl.lambda$doSend$5(AmqpSenderImpl.java:157)
at io.vertx.proton.impl.ProtonDeliveryImpl.fireUpdate(ProtonDeliveryImpl.java:158)
at io.vertx.proton.impl.ProtonTransport.handleSocketBuffer(ProtonTransport.java:160)
at io.vertx.core.net.impl.NetSocketImpl$DataMessageHandler.handle(NetSocketImpl.java:386)
at io.vertx.core.net.impl.NetSocketImpl.lambda$new$2(NetSocketImpl.java:101)
at io.vertx.core.streams.impl.InboundBuffer.handleEvent(InboundBuffer.java:237)
at io.vertx.core.streams.impl.InboundBuffer.write(InboundBuffer.java:127)
at io.vertx.core.net.impl.NetSocketImpl.handleMessage(NetSocketImpl.java:364)
at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:369)
at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:43)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:232)
at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:173)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:355)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:377)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:830)
As you guys can see, there is an message rejected and no more output, saying why this is happening. Prior to that i can also detect an: description='Deliveries cannot be sent to an unavailable address
Any idea why this is happening. Prior to this we had an JMS implementation with the same topics and that was working fine
Your AMQP broker may not "auto-create" the addresses, and so reject the messages.
Did you try to pre-configure your broker to create these addresses and their type (unicast / multicast) ?

Using node-rdkafka 2.5.1 version in my code to connect to kafka and it is crashing the connection after some time

From Node.js application I am trying to connect to Apache Kafka brokers(Version 0.11.0.3) using node-rdkafka client. The application is able to connect to kafka, subscribe to topics for a while but suddenly I see following error after about 1 and a half days in the logs(notice the timestamp). After these logs I can no longer see any successful connection to kafka. Which extra option do I need to avoid this error? There was no such error observed in Java codebase which is connecting to same kafka cluster.
Successful logs :
2019-03-15T07:15:24.364Z - [32minfo[39m: Producer receipt-svc#producer-1 ready
2019-03-15T07:15:24.410Z - [32minfo[39m: Consumer receipt-svc#consumer-2 ready
2019-03-15T07:15:24.411Z - [32minfo[39m: Subscribing to following topics : XXXX.XXXX.XXXX,XXXX.XXXX.XXXX,XXXX.XXXX.XXXX
2019-03-15T07:15:24.462Z - [32minfo[39m: Consumer receipt-svc#consumer-3 ready
2019-03-15T07:15:24.463Z - [32minfo[39m: Subscribing to following topics : XXXX.XXXX.XXXX
Error logs :
<------Kafka event log : Start ------->
2019-03-16T12:25:25.629Z - [32minfo[39m: severity=4, fac=METADATA, message=[thrd:main]: sasl_ssl://sl73kfkapp002.visa.com:8443/43: Metadata request failed: periodic refresh: Local: Required feature not supported by broker (0ms): Permanent
2019-03-16T12:25:25.630Z - [32minfo[39m: <------Kafka event log : End ------->
2019-03-17T12:30:26.301Z - [32minfo[39m: <------Kafka event log : Start ------->
2019-03-17T12:30:26.302Z - [32minfo[39m: severity=4, fac=METADATA, message=[thrd:main]: sasl_ssl://sl73kfkapp002.visa.com:8443/43: Metadata request failed: refresh unavailable topics: Local: Required feature not supported by broker (0ms): Permanent
2019-03-17T12:30:26.303Z - [32minfo[39m: <------Kafka event log : End ------->
Above logs are printed from following code piece
const consumer = new Kafka.KafkaConsumer(
{
"client.id": config["client.id"],
"group.id": config["group.id"],
"security.protocol": config["security.protocol"],
"metadata.broker.list": config["metadata.broker.list"],
"ssl.ca.location": config["ssl.ca.location"],
"ssl.certificate.location": config["ssl.certificate.location"],
"ssl.key.location": config["ssl.key.location"],
"ssl.key.password": this.machineKey.decrypt(config["ssl.key.password"]),
"sasl.kerberos.service.name": config["sasl.kerberos.service.name"],
"sasl.kerberos.principal": config["sasl.kerberos.principal"],
"sasl.kerberos.keytab": config["sasl.kerberos.keytab"]
},
{
"auto.offset.reset": "beginning",
"enable.auto.commit": true
}
);
consumer.on("event.log", function(log) {
logger.info("<------Kafka event log : Start ------->");
logger.info(log);
logger.info("<------Kafka event log : End ------->");
});
consumer.on("ready", function(arg) {
logger.info(`Consumer ${arg.name} ready`);
logger.info("Subscribing to following topics : " + topics);
consumer.subscribe(topics);
consumer.consume();
});
consumer.connect();

Flushing 0 Outstanding Messages For Offset Commit

I am writing my own Mqtt connector for Kafka. I know Confluent has Mqtt connector , but it is not open-source , so I decided to write my own connector.I have a problem about sending messages to Kafka. I can get Mqtt messages but can't send into Kafka. Basically, when a message comes from Mqtt Broker messageArrived method triggered , I am adding message into BlockingQueue like this:
private final BlockingQueue<SourceRecord> queue= new LinkedBlockingQueue<>();
#Override
public void messageArrived(String topic, MqttMessage message) throws Exception {
log.info("Message arrived : " + message.toString());
queue.add(new SourceRecord(null, null, kafkaTopic, null,
Schema.STRING_SCHEMA, message.getId(),
Schema.BYTES_SCHEMA, message.getPayload()));
}
And this is my poll method:
#Override
public List<SourceRecord> poll() throws InterruptedException {
List<SourceRecord> records = new ArrayList<SourceRecord>();
records.add(queue.take());
return records;
}
So, when I debug this code, the output as follows in console repeteadly:
[2019-03-13 17:45:37,113] INFO WorkerSourceTask{id=mqtt-connector-0} flushing 0 outstanding messages for offset commit (org.apache.kafka.connect.runtime.WorkerSourceTask)
[2019-03-13 17:45:40,385] INFO Message arrived : {"timestamp":1552488339305,"values":[{"id":"Simulation.Simulator.Temperature","v":1,"q":true,"t":1552488336813}]} (deneme.MqttSourceTask)
[2019-03-13 17:45:45,386] INFO Message arrived : {"timestamp":1552488344305,"values":[{"id":"Simulation.Simulator.Temperature","v":2,"q":true,"t":1552488341809}]} (deneme.MqttSourceTask)
[2019-03-13 17:45:48,204] INFO WorkerSourceTask{id=mqtt-connector-0} Committing offsets (org.apache.kafka.connect.runtime.WorkerSourceTask)
It seems, Mqtt messages come but can't send Kafka. These two methods work asynchronous by multiple threads.
When I write the queue.hashCode() to the console in both poll and messageArrived method, hashcode is different. It acts like seperate queue object. I don't understand why it is. What causes to this problem?
Can anyone tell me what is wrong?

Spring Integration JMS assured message delivery using DSL

I am trying to create a flow(1) in which message is received from TCP adapter which can be client or server and it sends the message to ActiveMQ broker.
My another flow(2) pick the message from required queue and send to the destination
TCP(client/server) ==(1)==> ActiveMQ Broker ==(2)==> HTTP Outbound adapter
I want to ensure that in case my message is not delivered to the required destination then it re-attempt to send the message again.
My current flow(1) to broker is :
IntegrationFlow flow = IntegrationFlows
.from(Tcp
.inboundAdapter(Tcp.netServer(Integer.parseInt(1234))
.serializer(customSerializer).deserializer(customSerializer)
.id("server").soTimeout(5000))
.id(hostConnection.getConnectionNumber() + "adapter"))).channel(directChannel())
.wireTap("tcpInboundMessageLogChannel").channel(directChannel())
.handle(Jms.outboundAdapter(activeMQConnectionFactory)
.destination("jmsInbound"))
.get();
this.flowContext.registration(flow).id("outflow").register();
and My flow(2) from broker to http outbound :
flow = IntegrationFlows
.from(Jms.messageDrivenChannelAdapter(activeMQConnectionFactory)
.destination("jmsInbound"))
.channel(directChannel())
.handle(Http.outboundChannelAdapter(hostConnection.getUrl()).httpMethod(HttpMethod.POST)
.expectedResponseType(String.class)
.mappedRequestHeaders("abc"))
.get();
this.flowContext.registration(flow).id("inflow").register();
Issue:
In case of any exception during delivery for example my destination URL is not working then it re attempt to send the message.
After unsuccessfull attempt it retry 7 times i.e max attempt to 7
If still the attempt is not successful then it send the message to ActiveMQ.DLQ (Dead letter Queue) and does not re-attempt again as message is dequeued from actual queue and send to ActiveMQ.DLQ.
So, i want the scenario that no message will be lost and message will be processed in order.
First: I believe that you can configure jmsInbound for the infinite retries:
/**
* Configuration options for a messageConsumer used to control how messages are re-delivered when they
* are rolled back.
* May be used server side on a per destination basis via the Broker RedeliveryPlugin
*
* #org.apache.xbean.XBean element="redeliveryPolicy"
*
*/
public class RedeliveryPolicy extends DestinationMapEntry implements Cloneable, Serializable {
On the other hand you can configure a .handle(Http.outboundChannelAdapter( for the RequestHandlerRetryAdvice for similar retry behavior but inside the application without round trips to the JMS and back: https://docs.spring.io/spring-integration/docs/5.0.6.RELEASE/reference/html/messaging-endpoints-chapter.html#retry-advice
Here is some sample how it can be configured from the Java DSL perspective:
#Bean
public IntegrationFlow errorRecovererFlow() {
return IntegrationFlows.from(Function.class, "errorRecovererFunction")
.handle((GenericHandler<?>) (p, h) -> {
throw new RuntimeException("intentional");
}, e -> e.advice(retryAdvice()))
.get();
}
#Bean
public RequestHandlerRetryAdvice retryAdvice() {
RequestHandlerRetryAdvice requestHandlerRetryAdvice = new RequestHandlerRetryAdvice();
requestHandlerRetryAdvice.setRecoveryCallback(new ErrorMessageSendingRecoverer(recoveryChannel()));
return requestHandlerRetryAdvice;
}
#Bean
public MessageChannel recoveryChannel() {
return new DirectChannel();
}
The RequestHandlerRetryAdvice can be configured with the RetryTemplate to apply something like AlwaysRetryPolicy. See Spring Retry project for more info: https://github.com/spring-projects/spring-retry

<int-jms:outbound-gateway> is not receiving reply messages

My <int-jms:outbound-gateway> is not sending messages to destination queue because of which i end up getting MessageTimeoutException.
I tried which worked perfectly and sent the messages which makes sure that i am getting correct messages on request-channel.
Also i see in logs that my outbound gatway is receiving the messages on requestCh1.
org.springframework.integration.jms.JmsOutboundGateway#0 received message: [Payload...]
I am really stuck and dont able to figure out why jms outbound gateway is not sending messages to destination queue.
Any help anybody ?
Config:
<int:publish-subscribe-channel id="requestCh1" />
<int:service-activator input-channel="requestCh1" ref="processor" method="processMsg"/>
<bean id="processor" class="com.processor.ProcessorImpl" />
<int-jms:outbound-gateway
id="eventPublisherGateway"
connection-factory="myConnectionFactory"
request-channel="requestCh1"
request-destination="qequestQueue"
reply-channel="responseCh1"
reply-destination="responseQueue"
receive-timeout="20000">
</int-jms:outbound-gateway>
Stacktrace:
07-15-2014 13:18:49 [threaPool.Thread-1] DEBUG AbstractMessageChannel$ChannelInterceptorList.preSend(334) | preSend on channel 'errorChannel', message: [Payload MessageTimeoutException content=org.springframework.integration.MessageTimeoutException: failed to receive JMS response within timeout of: 20000ms][Headers={id=7c81f473-e60e-30fa-b031-8106b3a2fff0, timestamp=1405444729344}]
07-15-2014 13:18:49 [threaPool.Thread-1] DEBUG AbstractMessageHandler.handleMessage(72) | (inner bean)#3dd4a538 received message: [Payload MessageTimeoutException content=org.springframework.integration.MessageTimeoutException: failed to receive JMS response within timeout of: 20000ms][Headers={id=7c81f473-e60e-30fa-b031-8106b3a2fff0, timestamp=1405444729344}]
07-15-2014 13:18:49 [threaPool.Thread-1] ERROR LoggingHandler.handleMessageInternal(145) | org.springframework.integration.MessageTimeoutException: failed to receive JMS response within timeout of: 20000ms
at org.springframework.integration.jms.JmsOutboundGateway.handleRequestMessage(JmsOutboundGateway.java:667)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:170)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
at org.springframework.integration.dispatcher.BroadcastingDispatcher.invokeHandler(BroadcastingDispatcher.java:160)
at org.springframework.integration.dispatcher.BroadcastingDispatcher.dispatch(BroadcastingDispatcher.java:142)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:255)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:223)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:109)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:44)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:94)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendMessage(AbstractReplyProducingMessageHandler.java:260)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendReplyMessage(AbstractReplyProducingMessageHandler.java:241)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.produceReply(AbstractReplyProducingMessageHandler.java:205)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleResult(AbstractReplyProducingMessageHandler.java:199)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:177)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
at org.springframework.integration.endpoint.PollingConsumer.handleMessage(PollingConsumer.java:74)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:205)
at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:55)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:149)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:146)
at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:284)
at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Adding JMS Message this gateways is sending with correlation id.
JMS Message class: jms_text
JMSType: null
JMSDeliveryMode: 2
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: ID:414d5120414344534430513720202020537502dd201b6c02
JMSTimestamp: 1405462485258
JMSCorrelationID:bf566441-8ccb-4620-afac-941cc4842a61
JMSDestination: queue://QMGR01/REQUESTQ
JMSReplyTo: queue://QMGR01/RESPONSEQ
JMSRedelivered: false
JMSXDeliveryCount:0
JMSXAppID:Websphere MQ Client for Java
JMS_IBM_PutApplType:28
timestamp:1405462384810
sequenceNumber:3
JMSXUserID:mqcls1
sequenceSize:4
JMS_IBM_PutTime:22574883
JMS_IBM_PutDate:20140715
<?xml version="1.0" encoding="UTF-8" standalone="no"?><Employee><empId>567</empId></<Employee>
Since you say that you get MessageTimeoutException and there is only one place in the JmsOutboundGateway where it is:
if (jmsReply == null) {
if (this.requiresReply) {
throw new MessageTimeoutException(message,
"failed to receive JMS response within timeout of: " + this.receiveTimeout + "ms");
}
else {
return null;
}
}
Hence your issue is around the reply not request.
I mean you send the message to the destination properly, but the other side doesn't send a reply to you to the responseQueue destination.
If you aren't interest in request/reply scenario and it's just enough to send messages, you can switch to the <int-jms:outbound-channel-adapter>.
If it isn't truth, show, please, the StackTrace to see where your MessageTimeoutException is caused.
UPDATE
Can this be because of JmsCorrelationId ?
Yes it can. The another part has to support the JMSCorrelationID property with a value from the request.
JmsOutboundGateway does the correlation by selector:
messageSelector = "JMSCorrelationID = '" + correlationId + "'";
...
messageConsumer = session.createConsumer(replyTo, messageSelector);

Resources