Announcement Announcement Module
Collapse
No announcement yet.
Simple example of MDP Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simple example of MDP

    Hi
    I would like to use Spring MDP. I am following the documentation here: http://static.springframework.org/sp...rence/jms.html
    Section 19.4.2 .
    The part that I am missing is how should my JMS receiver code should look like?
    Note: I am using JMS outside J2EE container. My Server and Client are 2 tiny java programs.
    Note I am using "home grown" JMS provider.

    My client code:
    ...
    public static void main(String[] args) {
    ApplicationContext ctx = new FileSystemXmlApplicationContext(
    new String[] {"./spring-config/conf-server.xml","./spring-config/demo.xml"}
    );
    JmsTemplate template = (JmsTemplate) ctx.getBean("jmsTemplate");
    Destination destination = (Destination)ctx.getBean("destination");
    template.send(destination, new MessageCreator() {
    public Message createMessage(Session session) throws JMSException {
    return session.createTextMessage("Hello World (using Spring JMS Template)");
    }
    });
    System.out.println("Message was sent..");
    }
    ...
    My server code: (not working..)
    ...
    ApplicationContext ctx = new FileSystemXmlApplicationContext(
    new String[] {"./spring-config/conf-server.xml","./spring-config/demo.xml"}
    );
    DefaultMessageListenerContainer container = (DefaultMessageListenerContainer) ctx.getBean("jmsContainer");

    container.initialize();

    container.start();

    System.out.println("AsyncSpringReceiver was started..");
    ...
    Configuration:
    conf-client.xml:
    <beans>
    <!-- configure connection factory -->
    <bean id="connectionFactory" class="com.marimba.jms.MRBAQueueConnectionFactory" >
    <constructor-arg index="0">
    <props>
    <prop key="master">http://172.16.233.50:5282/m7202/InventoryService</prop>
    <prop key="root.directory">c:\\tmp\\jmsserver</prop>
    <prop key="client.id">MyClient</prop>
    </props>
    </constructor-arg>
    </bean>

    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory">
    <ref local="connectionFactory"/>
    </property>
    </bean>
    </beans>

    conf-server.xml
    <beans>
    <!-- configure connection factory -->
    <bean id="connectionFactory" class="com.marimba.jms.MRBAQueueConnectionFactory" >
    <constructor-arg index="0">
    <props>
    <prop key="master">http://172.16.233.50:5282/m7202/InventoryService</prop>
    <prop key="root.directory">c:\\tmp\\jmsserver</prop>
    <prop key="client.id">MyServer</prop>
    </props>
    </constructor-arg>
    </bean>

    <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory">
    <ref local="connectionFactory"/>
    </property>
    </bean>

    <!-- this is the Message Driven POJO (MDP) -->
    <bean id="messageListener" class="com.marimba.jms.test.MessgeDrivenPojo" />

    <!-- and this is the message listener container -->
    <bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMes sageListenerContainer">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="destination" ref="destination"/>
    <property name="messageListener" ref="messageListener" />
    </bean>
    </beans>
    demo.xml

    <beans>
    <bean id="destination" class="com.marimba.jms.MRBAQueue">
    <constructor-arg index="0">
    <value>MyClient</value>
    </constructor-arg>
    <constructor-arg index="1">
    <value>QueueDemoName</value>
    </constructor-arg>
    </bean>
    </beans>

    So what I am asking is how should the Server code looks like?

    Thanks

    Avishay
Working...
X