SwiftMQ URL解析器无法解析正确的URL

时间:2012-07-09 16:04:38

标签: java spring jms

当我尝试发送消息时,我收到以下异常。 URL似乎是正确的,之前我使用过类似的配置。我不知道可能导致这个问题的原因......

Caused by: javax.naming.NamingException: invalid URL: protocol != smqp, URL==smqp://activemq:3001/timeout=10000
    at com.swiftmq.jndi.v400.URLParser.parseURL(Unknown Source)
    at com.swiftmq.jndi.InitialContextFactoryImpl.getInitialContext(Unknown Source)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
    at javax.naming.InitialContext.init(InitialContext.java:223)
    at javax.naming.InitialContext.<init>(InitialContext.java:197)
    at org.springframework.jndi.JndiTemplate.createInitialContext(JndiTemplate.java:136)
    at org.springframework.jndi.JndiTemplate.getContext(JndiTemplate.java:103)
    at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:85)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:152)
    at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:178)
    at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
    at org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:105)
    at org.springframework.jndi.JndiObjectTargetSource.getTarget(JndiObjectTargetSource.java:127)
    ... 50 more

配置

<!-- JMS Connection Factory -->
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
        <props>
            <prop key="java.naming.provider.url">smqp://activemq:3001/timeout=10000</prop>
            <prop key="java.naming.factory.initial">com.swiftmq.jndi.InitialContextFactoryImpl</prop>
        </props>
    </property>
</bean>

<bean id="jmsConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiTemplate" ref="jndiTemplate" />
    <property name="jndiName" value="QueueConnectionFactory" />
    <property name="lookupOnStartup" value="false" />
    <property name="cache" value="false" />
    <property name="proxyInterface" value="javax.jms.QueueConnectionFactory" />
</bean>

<bean id="sendConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory" destroy-method="destroy">
    <property name="targetConnectionFactory" ref="jmsConnectionFactory" />
    <property name="reconnectOnException" value="true" />
    <property name="sessionCacheSize" value="100"/>
</bean>

<!-- Template used only for sending messages -->
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="sendConnectionFactory" />
    <property name="defaultDestinationName" value="request@z4smq_4001" />
</bean>

用法

MessageCreator messageCreator = new MessageCreatorImpl(payload);
jmsTemplate.send(messageCreator); // setter injection

1 个答案:

答案 0 :(得分:0)

“smqp://”前面是否有空格或任何其他不可见字符?在那种情况下,我得到相同的例外,否则它对我有用。

您应该将问题发布到SwiftMQ的user forum,以便与适当的受众群体联系。