Anyone know if you can create a topic and its connection factory programatically? Currently i use the glassfish admin utility to create my topic and its connection factory. If i can't create it in code does glassfish/openmq have a default topic and conn factory i can use?
相关问题
- How do I delay JMS Message sending?
- Is JavaEE really portable?
- Reducing line width of glassfish log
- Glassfish 4.1 - Latest Jersey version
- How to get Spring to wire my JmsComponent
相关文章
- Spring JMS : Set ErrorHandler for @JmsListener ann
- The JavaEE 8 Tutorial, deploy failed on hello1 pro
- When sending XML to JMS should I use TextMessage o
- ClassCastException: javax.naming.Reference cannot
- Stacktrace does not print in Glassfish 4.1 Cluster
- GlassFish (real) hot deployment of JSF pages and r
- Java Web Application multiple user session handlin
- GlassFish 5 and MySQL Connector
If you only want to circumvent creating the resources manually in the admin you can simply deploy them with the file "glassfish-resources.xml" (GF 3.1, see http://docs.oracle.com/cd/E18930_01/html/821-2417/giyhh.html).
You need an admin-object-resource like this one (for a topic):
Be aware that you must use different "Name" values for the Topic (here: "physicalTopic") if you implement multiple Topics whose messages should not get mixed up.
Further you need a connector-resource referencing a connector-connection-pool of type javax.jms.TopicConnectionFactory.
If you don't aim for dynamically creating resources using the deployment descriptor glassfish-resources.xml seems to be the best way.
Please note that resources deployed that way are application-scoped: http://docs.oracle.com/cd/E18930_01/html/821-2417/giydj.html
"glassfish-resources.xml" is the file for GF 3.x, for GF 2.x it was "sun-resources.xml". The file is located in the "Server Resources" folder in your project view if you are using NetBeans. Attention: the glassfish-resources.xml in "Server Resources" is only used by NetBeans if you use NetBeans to deploy! NetBeans knows how to create theses resources and conducts this task. If you deploy an EAR directly to Glassfish without NetBeans -- which seems very likely for a production environment -- you have to provide glassfish-resources.xml in:
You can easily create this resource definition by using NetBeans' [New Message-Driven Bean] wizard (simply add an MBean by selecting [New ...]). In the wizard choose "Project Destinations" > [Add]. A complete 3.1 example looks like this:
This is the MBean annotation:
Caution: "java:app/" in mappedName is correct only if you use application scoped resources. You can spare "java:app/" in the definition in glassfish-resources.xml. The GF deployment guide says: "Application-scoped resource JNDI names begin with java:app or java:module. If one of these prefixes is not specified in the JNDI name, it is added."
You can also introduce another level of indirection by using "name" instead of "mappedName". You then have to provide a file named "application-client.xml" where the (logical) name gets mapped to an JNDI "physical" location.