我无法从旧的JBoss迁移到Wildfly 14(或其他一些最新版本)。
目前,我坚持使用JMS配置。
配置如下:
@members = User.order("id DESC")
if current_user.admin_level < 8
@members = @members.where("country = ?", current_user.country)
end
中,我用以下代码添加了两个队列定义# extension .yaml .yml
# hashtag to add comments
Person:
name: "ashutosh kale"
profile: "Devloper"
age : &store 21
isreteired: false #null
marks: 55.23
flaws: null
birthday : 07-03-1997 11:10:23 #ISO 8601 standard.
hobbies :
- photography
- gamming
- reading
movies : &fewhour ["Batman","Inception","UP"] #this is another methods to declare
friends :
- Name : "ganesh"
age : 24
- Name : "Varad"
age : 25
- Name : "xyz"
age : 23
- {name : "abc", age : 30} #Method 2
description : > # '<' render into single lines [so no space]
wfsdf wdflsd spodjfsd spdfjksd [sdvlknx]
wdflksdl dsvsdkl wovnodfen wr eflvnef wvknv
wdfm;wdlkn wnvlkefnv efvklef epivldkf fvnfv
vef;lvm epfivief efnvjkd eofnvjefn fovnefn eefjnvef
fvlfnvldfk epfinvnfev pfoiefnv epifnvoefn pfeinvjkef
fevnlefnv ejfnvjkefv poefnvklef
about : | #render with space.
wfsdf wdflsd spodjfsd spdfjksd [sdvlknx]
wdflksdl dsvsdkl wovnodfen wr eflvnef wvknv
wdfm;wdlkn wnvlkefnv efvklef epivldkf fvnfv
vef;lvm epfivief efnvjkd eofnvjefn fovnefn eefjnvef
fvlfnvldfk epfinvnfev pfoiefnv epifnvoefn pfeinvjkef
fevnlefnv ejfnvjkefv poefnvklef
isbig: *store #my age get stored....
series : &fewdays
- person of intrest
- suits
- this is us
- game of thrones
- daredevil
timewasted :
<<: *fewhour
yearwasted :
<<: *fewdays
<subsystem xmlns="urn:jboss:domain:messaging-activemq:4.0">
在我的课堂上,我有以下字段
<jms-queue name="MyQueue" entries="java:/jms/queue/MyQueue"/>
<jms-queue name="OtherQueue" entries="java:/jms/queue/OtherQueue"/>
在这个课程中,我有以下方法:
<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm" />
第private static final String JMS_CONNECTION_FACTORY_JNDI_NAME = "java:/ConnectionFactory";
@Resource(mappedName=JMS_CONNECTION_FACTORY_JNDI_NAME)
ConnectionFactory factory;
行会抛出NPE,因为factory为null。
答案 0 :(得分:1)
具有以下配置:
<connection-factory name="InVmConnectionFactory" entries="java:/ConnectionFactory" connectors="in-vm"/>
我正在使用以下代码:
@Resource(mappedName = "java:/ConnectionFactory")
private static ConnectionFactory connectionFactory;
希望这会有所帮助。
答案 1 :(得分:0)
In case you just need to access a JMS queue, there is probably a shorter way to do it (using the simplified api of JMS 2.0):
Config:
<jms-queue name="esb.inbound.test" entries="java:/jms/queue/esb.inbound.test"/>
Code:
@Resource(mappedName="java:/jms/queue/esb.inbound.test")
private Queue inboundQueue;
答案 2 :(得分:0)
以下方法对我有用:
@Stateless
和@LocalBean
批注标记您的bean。添加此对象后,您的bean将成为容器管理的对象,您可以依靠它。同样,在初始上下文创建时,您不应指定任何属性。初始上下文创建应类似于:private static Context getInitialContext() throws NamingException
{ return new
InitialContext(); }
将wildfly-ejb-client-bom,wildfly-jms-client-bom,wildfly-naming添加到您的Maven依赖项中。在您的客户端代码中,使用JMS队列和连接工厂的完整JNDI名称。例如:
queue/MySuperJMSQueue
之前,java:/jms/queue/MySuperJMSQueue
之后ConnectionFactory
之前,之后:java:/ConnectionFactory
通过以下行添加新的JMS队列来更改配置文件(在我的情况下为standalone-full.xml):
<jms-queue name="MySuperJMSQueue" entries="java:/jms/queue/MySuperJMSQueue"/>
更改用于初始上下文实例化的参数:
private static Context getInitialContext() throws NamingException {
Properties props = new Properties();
props.put( Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
props.put( Context.URL_PKG_PREFIXES, "org.jboss.as.naming.interfaces:org.jboss.ejb.client.naming");
return new InitialContext(props);
}
完成这些操作后,您就可以使用JMS。只是打开JMS会话的示例:
Context jndiContext = getInitialContext();
ConnectionFactory factory = (ConnectionFactory) jndiContext.lookup(JMS_CONNECTION_FACTORY_JNDI_NAME);
connection = factory.createConnection();
queue =(Queue) jndiContext.lookup(JMS_QUEUE_NAME);
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
有关更多详细信息,请检查以下路径中的文档:<WildFly 14 home folder>\bin\client\README-EJB-JMS.txt