-2

I defined producer template using camel

<camel:template id="msgProducerTemplate" />

I am injecting this bean into one of my services to produce messages.

msgProducerTemplate.sendBodyAndHeaders(endpointUri, message, headerMap);

For all the messages this produces the correlationID generated is same, how can I make it to create a new id for each message, even if the actual message is identical.

My endpointUri is inboundTopic:topic:${topic.name}

My jmscomponent is defined as below...

<bean id="inboundTopic" class="org.apache.camel.component.jms.JmsComponent">
    <property name="connectionFactory" ref="jmsTopicConnectionFactory" />
    <property name="destinationResolver" ref="topicDestinationResolver" />
    <property name="transacted" value="true" />
    <property name="transactionManager" ref="topicTxManager" />
    <property name="cacheLevelName" value="CACHE_CONSUMER" />
</bean>

<bean id="topicConnectionFactory" class="com.ibm.mq.jms.MQTopicConnectionFactory">
    <property name="hostName" value="${queuehost}" />
    <property name="port" value="${queueport}" />
    <property name="queueManager" value="${queuemanager}" />
    <property name="channel" value="${channel}" />
    <property name="transportType" value="${transportType}" />
</bean>

<bean id="jmsTopicConnectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
    <property name="targetConnectionFactory" ref="topicConnectionFactory" />
    <property name="username">
        <value>${userid}</value>
    </property>
</bean>

<bean id="topicDestinationResolver" class="com.abc.jms.JMSTopicDestinationResolver" />
Sri
  • 21
  • 4
  • It depends on how you configured JMS component and the JMS endpoint you send to etc. You need to provide more details, and also read more about the JMS component and how request/reply works. – Claus Ibsen Nov 07 '17 at 08:06
  • @ClausIbsen updated the question. – Sri Nov 07 '17 at 17:25
  • And are you sure you dont provide an existing JMSCorrelationID in the headers you pass to the producer template. eg you can debug and/or enable DEBUG/TRACE logging and see what is going on. – Claus Ibsen Nov 08 '17 at 09:19
  • Yes I am sure i am not setting the correlationID. I did try setting JMSCorrelationID, at which point it works fine. – Sri Nov 08 '17 at 14:04
  • It may be the JMS broker you are using. Camel does not automatic set any JMSCorrelationID when you use InOnly messaging (not request/reply). CorrelationID's are only in use when you use InOut (request/reply). It may be the JMS client you are using that does something (eg IBM MQ). – Claus Ibsen Nov 08 '17 at 14:24

1 Answers1

0

Just add JMSCorrelationID header.

Eg.

headerMap.put("JMSCorrelationID", UUID.randomUUID().toString());
Bedla
  • 4,789
  • 2
  • 13
  • 27
  • I know that will fix the issue, but why should I do that? – Sri Nov 06 '17 at 22:03
  • 1
    You have not mentioned which component you are using. ExchangePattern and other endpoint options are also relevant, so this is the only answer I can provide at the moment. To be able answer please provide full endpointUri, content of headerMap and used camel version. – Bedla Nov 06 '17 at 23:27