是否有人将Grails 2.x JMS插件配置为向远程WebLogic JMS服务器发送/接收消息?我已经尝试过像这样的resources.groovy配置而没有运气:
jmsConnectionFactory(InitialContext, [
"INITIAL_CONTEXT_FACTORY": "weblogic.jndi.WLInitialContextFactory",
"PROVIDER_URL": "t3://remote-host:7001",
"SECURITY_PRINCIPAL": "weblogic",
"SECURITY_CREDENTIALS": "weblogic"])
答案 0 :(得分:0)
关于使用远程Weblogic服务器在Grails中发送/接收JMS的全部答案并不多,所以我在2 - 3年前找到了一个工作解决方案,不需要任何插件。
确保至少Weblogic wlthint3client.jar位于lib目录中。
设置JMS 侦听器:
在conf / spring / resources.groovy中:
PI<angle_max<=2PI
:
// Weblogic's JMS setup on Grails
jndiTemplate(org.springframework.jndi.JndiTemplate) {
environment = [
"java.naming.factory.initial" : "weblogic.jndi.WLInitialContextFactory",
"java.naming.provider.url" : "t3://host.name.mustbe.same.as.configured.on.server.side:port_number",
"java.naming.security.principal" : "wlsadmin",
"java.naming.security.credentials": "password"
]
}
//
// listener
//
jmsListenerConnectionFactory(org.springframework.jndi.JndiObjectFactoryBean) {
jndiTemplate = ref(jndiTemplate)
jndiName = "jms.checkonserver.QueueConnectionFactory"
}
jmsListenerDestinationResolver(org.springframework.jms.support.destination.JndiDestinationResolver) {
jndiTemplate = ref(jndiTemplate)
cache = false
}
userListenerCredentialsConnectionFactory(org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter){
targetConnectionFactory = ref(jmsListenerConnectionFactory)
}
standardListenerJmsTemplate(org.springframework.jms.core.JmsTemplate) {
connectionFactory = ref(userListenerCredentialsConnectionFactory)
destinationResolver = ref(jmsListenerDestinationResolver)
}
jmsListenerMessageListener(org.springframework.jms.listener.adapter.MessageListenerAdapter, ref("myListenerService")) {
defaultListenerMethod = "onMessage"
}
standardListenerJmsListenerContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) {
connectionFactory = ref(jmsListenerConnectionFactory)
destinationResolver = ref(jmsListenerDestinationResolver)
messageListener = jmsListenerMessageListener
destinationName = "jms.checkonserver.MessagesQueue"
}
设置JMS 发件人:
在conf / spring / resources.groovy中:
package app
class MyListenerService {
static transactional = false
static scope = "prototype"
def onMessage(msg) {
log.info "JMS msg received."
try {
String txtmsg = new String(msg as String)
log.info txtmsg
} catch (e) {
log.error e
}
}
}
/ myJmsSenderService.groovy:
jmsSenderConnectionFactory( org.springframework.jndi.JndiObjectFactoryBean) {
jndiTemplate = ref(jndiTemplate)
jndiName = "jms.checkonseerver.QueueConnectionFactory"
}
jmsSenderDestinationResolver(org.springframework.jms.support.destination.JndiDestinationResolver) {
jndiTemplate = ref(jndiTemplate)
cache = false
}
userSenderCredentialsConnectionFactory(org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter){
targetConnectionFactory = ref(jmsSenderConnectionFactory)
}
standardSenderJmsTemplate(org.springframework.jms.core.JmsTemplate) {
connectionFactory = ref(userSenderCredentialsConnectionFactory) //
destinationResolver = ref(jmsSenderDestinationResolver)
}