Reputation: 161
I have the below configuration which will connect to a particular queue on jms and will consume message from that queue and will write to a file
now the issue is that on the queue the message is of type object type or of string type also and i want to consume object type message only
so for example below is the body of the message which is of object type so the message headers value is
ObjectMessage={ Header={ JMSMessageID={ID:LON_TEST_GAWE_4533.351656B16070206DEBAE:1936} JMSDestination={Queue[erty.retry.object]} JMSReplyTo={null} JMSDeliveryMode={PERSISTENT} JMSRedelivered={false} JMSCorrelationID={null} JMSType={null} JMSTimestamp={Fri Feb 26 11:52:53 IST 2016} JMSExpiration={0} JMSPriority={4} } Properties={ } Object={?} }
as you have notice above that for object message the initials text in the message headers begains with ObjectMessage={ Header={ JMSMessageID={ID:LON
so please advise how can i consume all object type message is there any way by which i can them and store them in a file
bwlow is my configuration rite now..
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:jms="http://www.springframework.org/schema/integration/jms"
xmlns:file="http://www.springframework.org/schema/integration/file"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/jms
http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
http://www.springframework.org/schema/context/spring-context.xsd">
<int:poller id="poller" default="true">
<int:interval-trigger interval="200" />
</int:poller>
<int:channel id="input">
<int:queue capacity="10" />
</int:channel>
<bean id="tibcoEMSJndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">com.tibco.tibjms.naming.TibjmsInitialContextFactory
</prop>
<prop key="java.naming.provider.url">tcp://wert2.fm.absgrp.net:3453</prop>
<prop key="java.naming.security.principal">aert</prop>
<prop key="java.naming.security.credentials">aert</prop>
</props>
</property>
</bean>
<bean id="tibcoEMSConnFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="tibcoEMSJndiTemplate" />
</property>
<property name="jndiName">
<value>GenericConnectionFactory</value>
</property>
</bean>
<bean id="tibcosendJMSTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref bean="tibcoEMSConnFactory" />
</property>
<property name="defaultDestinationName">
<value>erty.retry.object</value>
</property>
<property name="pubSubDomain">
<value>false</value>
</property>
<property name="receiveTimeout">
<value>120000</value>
</property>
</bean>
<!-- <jms:outbound-channel-adapter channel="input"
destination-name="erty.retry.object" connection-factory="tibcoEMSConnFactory" /> -->
<jms:message-driven-channel-adapter id="jmsIn" concurrent-consumers="10"
destination-name="erty.retry.object" connection-factory="tibcoEMSConnFactory" extract-payload="false"
channel="jmsInChannel" />
<int:channel id="jmsInChannel" />
<file:outbound-channel-adapter id="filesout" channel="jmsInChannel" directory="C:\\dfgal"
filename-generator="generatorr" />
<bean id="generatorr" class="com.rbs.tibco.TimestampTextGenerator">
</bean>
<int:payload-type-router input-channel="jmsInChannel"></int:payload-type-router>
<bean id="generatorr" class="com.rbs.tibco.TimestampTextGenerator">
</bean>
</beans>
Upvotes: 0
Views: 721
Reputation: 121542
Seems for me I have seen similar question here on SO. I don't want to find it to be sure that was from you and there was some answer.
Please, be sure that you use the search before asking unclear questions.
First of all your solution looks weird from the architecture perspective.
Even if we can do something like that, the JMS isn't so flexible to be partitioned like it is possible with Kafka.
I mean that it isn't so convenient for the consumer to read different message types from the same queue. The main problem that consumers reads ALL messages from the queue. I'm not sure that just filter those text messages and drop them is a good solution for your system.
Anyway you can use extract-payload = "false"
on the <jms:message-driven-channel-adapter>
meaning that the whole JMS Message
will be as Spring Integration Message payload
. After that you can use <payload-type-router>
and distinguish an ObjectMessage
from TextMessage
and send them to the different channel: the first one to store in the file, another to something else.
Hope I am clear.
Upvotes: 1