Announcement Announcement Module
Collapse
No announcement yet.
Does Spring support the JMS Provider: Sun Java System Message Queue, v3.6? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Does Spring support the JMS Provider: Sun Java System Message Queue, v3.6?

    Hi,

    I was wondering if Spring supports the JMS provider from Sun called Sun Java System Message Queue?

    If, so any working XML JMSTemplate examples would be most excellent.

    Thanks in advance!

  • #2
    Hi,

    because Sun Java Message System is fully jms compliant, it is supported out-of-the-box throuhg spring. You can use JMSTemplate to send and receive (synchronus) messages.

    AFAIK the best sample is the reference documentation and perhaps like in all classes the particular java docs :-)

    Have a look here

    http://static.springframework.org/sp...rence/jms.html

    regards
    agim

    Comment


    • #3
      Solution for Open Message Queue configuration under Spring

      Here is a solution to allow Spring to manage/configure a JMS Connection using Open Message Queue.

      I wish to Thank Michael Bingham a Senior Consultant at SpringSource for all his time and effort in crafting this solution... As the instructor for the Core Spring course in Denver he has elevated my understanding of Spring core components, way more than any book could possibly perform ( I have three books so far..). His intimate knowledge of the product was comprehensive. He also went above and beyond his duties by providing assistance after the class in support of my issues. If you have the chance to take the Core Spring class instructed by Michael Bingham it is awesome and will jump start your Spring knowledgebase quickly.. Thanks again Michael!!!

      Here are the two parts of the solution:

      Open Message Queue Connection Factory:
      Code:
      public class OpenMqConnectionFactoryBean implements FactoryBean
      {
          // Class variables
          private String imqAddressList;
          private String imqDefaultUsername;
          private String imqDefaultPassword;
      
          // Preferred mechanism for instantiating a Logger for this class
          private static VtlLogger logger = VtlLogger.getInstance();
      
          /*
           * (non-Javadoc)
           * 
           * @see org.springframework.beans.factory.FactoryBean#getObject()
           */
          public Object getObject() throws JMSException
          {
              ConnectionFactory factory = new com.sun.messaging.ConnectionFactory();
              try
              {
                  // Set the IMQ Broker Connection URL
                  factory.setProperty(ConnectionConfiguration.imqAddressList, this.getImqAddressList());
      
                  // Set the IMQ Default Username
                  factory.setProperty(ConnectionConfiguration.imqDefaultUsername, this.getImqDefaultUsername());
      
                  // Set the IMQ Default Password
                  factory.setProperty(ConnectionConfiguration.imqDefaultPassword, this.getImqDefaultPassword());
              }
              catch (JMSException jmse)
              {
                  // Print Stack Trace of the JMS Exception
                  logger.error("unknown", getClass(), "start", "JMS Exception ==> " + factory.getClass().getCanonicalName() + ", Class=" + factory.getClass().getName() + ", Error=" + jmse.toString());
                  jmse.printStackTrace();
                  throw jmse;
              }
              return factory;
          }
      
          /**
           * 
           */
          public void setImqAddressList(String imqAddressList)
          {
              this.imqAddressList = imqAddressList;
          }
      
          /**
           * @return the imqAddressList
           */
          public String getImqAddressList()
          {
              return this.imqAddressList;
          }
      
          /**
           * @return the imqDefaultUsername
           */
          public String getImqDefaultUsername()
          {
              return this.imqDefaultUsername;
          }
      
          /**
           * @param imqDefaultUsername
           *            the imqDefaultUsername to set
           */
          public void setImqDefaultUsername(String imqDefaultUsername)
          {
              this.imqDefaultUsername = imqDefaultUsername;
          }
      
          /**
           * @return the imqDefaultPassword
           */
          public String getImqDefaultPassword()
          {
              return this.imqDefaultPassword;
          }
      
          /**
           * @param imqDefaultPassword
           *            the imqDefaultPassword to set
           */
          public void setImqDefaultPassword(String imqDefaultPassword)
          {
              this.imqDefaultPassword = imqDefaultPassword;
          }
      
          /*
           * (non-Javadoc)
           * 
           * @see org.springframework.beans.factory.FactoryBean#getObjectType()
           */
          @Override
          public Class<ConnectionFactory> getObjectType()
          {
              // Returns Sun JMS Connection Factory class type
              return ConnectionFactory.class;
          }
      
          /*
           * (non-Javadoc)
           * 
           * @see org.springframework.beans.factory.FactoryBean#isSingleton()
           */
          @Override
          public boolean isSingleton()
          {
              // Does not support singleton usage
              return false;
          }
      
      }
      Spring XML:
      Code:
      	<!--  Custom Open MQ Connection Factory -->
      	<bean id="mqConnectionFactory"
      		class="com.sun.evtl.mq.util.OpenMqConnectionFactoryBean">
      		<property name="imqAddressList" value="mq://localhost:7676/" />
      		<property name="imqDefaultUsername" value="admin" />
      		<property name="imqDefaultPassword" value="xxxxxxxx" />
      	</bean>
      
      	<bean id="jmsTemplate"
      		class="org.springframework.jms.core.JmsTemplate">
      		<property name="connectionFactory" ref="mqConnectionFactory" />
      	</bean>

      Comment

      Working...
      X