Points to remember : Java Messaging Service and Spring WebService

Spring Web Service can be easily integrated in a Messaging environment with the help of Java Messaging Service, we need to keep some basic points in mind while handling messages using JMS and Spring WS, these are given below and will be helpful in interviews too.
1) You need JMS jar in your class path to use JMS with Spring Webservice.
2) DefaultMessageListenerContainer  uses plain JMS client API, specifically a loop of MessageConsumer.receive() calls that also allow for transactional reception of messages (registering them with XA transactions). Designed to work in a native JMS environment as well as in a J2EE environment, with only minimal differences in configuration.
3) Generally to set the MessageListener of  DefaultMessageListenerContainer for incoming messages WebServiceMessageListener is used and configured like below:
  1. <property name="messageListener">
  2. <bean class="org.springframework.ws.transport.jms.WebServiceMessageListener>
  3. <property name="messageFactory" ref="messageFactory" />
  4. <property name="messageReceiver" ref="messageDispatcher" />
  5. </bean>
  6. </property>
4) The connectionfactory and messagedispatcher are configured in the Listener as shown above.
5) The MessageDispatcher sets the endpoint mapping and its type.You need to an endpoint class either by annotating a class with @Endpoint, @PayloadRoot or you need to define a bean as an endpoint in the context file like below,
  1. <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
  2. <property name="defaultEndpoint">
  3. <bean class="…
6) The main entrypoint is invoke(Source) method of the endpoint, which gets invoked with the contents of the requesting message .i.e when a request arrives at the server, and possibly returns a response.
7) Spring Web Services provides a WebServiceMessageDrivenBean, an EJB MessageDrivenBean

Comments

Popular posts from this blog

Java Interview : Threads

Spring Framework Interview Notes : Part Two Wiring

Card Dealer In Java in Less than 5 minutes