Announcement Announcement Module
Collapse
No announcement yet.
SocketTimeoutException when initializing JMS Destination Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SocketTimeoutException when initializing JMS Destination

    I am porting an old JMS client implementation to use Spring instead. The old implementation works fine, but doing the same using Spring results in some strange errors. When my jmsDestination bean is initilized, I receive a CommunicationException (with SocketTimeoutException as the cause):

    javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out

    The old implementation does everything programatically:

    Code:
    System.setProperty("jboss.messaging.callback.bind.port", callBackPort);
    System.setProperty("jboss.messaging.callback.bind.address", callBackIP);
    
    Properties props = new Properties();
    props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
    props.put(Context.PROVIDER_URL, remoteJmsUrl);
    props.put(Context.SECURITY_PRINCIPAL, username);
    props.put(Context.SECURITY_CREDENTIALS, password);
    
    InitialContext ctx = new InitialContext(props);
    ConnectionFactory qcf = (ConnectionFactory) ctx.lookup("/ConnectionFactory");
    Connection qConn = qcf.createConnection(username, password);
    
    Session qSession = qConn.createSession(false, QueueSession.AUTO_ACKNOWLEDGE);
    
    Queue q = (Queue) ctx.lookup(jmsQueueName);
    
    qConn.start();
    
    MessageConsumer msgConsumer = qSession.createConsumer(q);
    while ((oMsg = (TextMessage) msgConsumer.receiveNoWait()) != null) {
      // Parse the message...
    }
    I'm guessing the setting of the System properties for the callback port and IP has something to do with it. When I try to do the same using Spring I get the exception above. I tried setting them for JBoss during startup (added -D parameters in run.conf), but that didn't help. Any suggestions on how to solve this?

    The application-context XML for the MessageListener looks like this:

    Code:
    <bean id="messageListener" class="com.server.jms.MessageListenerTest" />
    
    <bean id="connectionFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
    	<property name="username" value="username" />
    	<property name="password" value="password" />
    	<property name="targetConnectionFactory">
    		<bean class="org.springframework.jndi.JndiObjectFactoryBean">
    			<property name="jndiEnvironment">
    				<props>
    					<prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
    					<prop key="java.naming.provider.url">jnp://jms.server.com:1099</prop>
    					<prop key="java.naming.factory.url.pkgs">org.jnp.interfaces:org.jboss.naming</prop>
    					<prop key="java.naming.security.principal">username</prop>
    					<prop key="java.naming.security.credentials">password</prop>
    					<prop key="jboss.messaging.callback.bind.port">3000</prop>
    					<prop key="jboss.messaging.callback.bind.address">123.123.123.123</prop>
    				</props>
    			</property>
    			<property name="lookupOnStartup" value="false" />
    			<property name="jndiName" value="/ConnectionFactory"/>
    			<property name="proxyInterface" value="javax.jms.ConnectionFactory" />
    			<property name="resourceRef" value="false"/>
    		</bean>
    	</property>
    </bean>
    
    <bean id="jmsDestination" class="org.springframework.jndi.JndiObjectFactoryBean">
    	<property name="jndiName" value="/queue/RemoteQueueName"/>
    	<property name="lookupOnStartup" value="true" />
    	<property name="proxyInterface" value="javax.jms.Queue" />
    	<property name="resourceRef" value="false"/>
    </bean>
    
    <bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    	<property name="concurrentConsumers" value="1"/>
    	<property name="connectionFactory" ref="connectionFactory"/>
    	<property name="destination" ref="jmsDestination"/>
    	<property name="messageListener" ref="messageListener"/>
    </bean>
    Thanks!

    // Erik
Working...
X