Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6933911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:53:34+00:00 2026-05-27T11:53:34+00:00

Anyone know if you can create a topic and its connection factory programmatically? Currently

  • 0

Anyone know if you can create a topic and its connection factory programmatically? 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:53:34+00:00Added an answer on May 27, 2026 at 11:53 am

    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):

    <admin-object-resource enabled="true" jndi-name="jms/myTopic"
       object-type="user" res-adapter="jmsra" res-type="javax.jms.Topic">
      <property name="Name" value="physicalTopic"/>
    </admin-object-resource>
    

    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:

    • META-INF of your EJB module or WEB-INF of your WAR for module scoped resources
    • META-INF of your enterprise application for application wide resources
      In NetBeans you accomplish this by placing the file into the “Configuration Files” folder of your project view (which is src/conf/ in the file system).

    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:

    <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
    <resources>
        <admin-object-resource enabled="true" jndi-name="jms/myDestination"  res-type="javax.jms.Topic"  res-adapter="jmsra">
            <property name="Name" value="PhysicalTopic"/>
        </admin-object-resource>
        <connector-connection-pool name="jms/myDestinationFactoryPool"  connection-definition-name="javax.jms.TopicConnectionFactory"  resource-adapter-name="jmsra"/>
        <connector-resource enabled="true" jndi-name="jms/myDestinationFactory" pool-name="jms/myDestinationFactoryPool"  />
    </resources>
    

    This is the MBean annotation:

    @MessageDriven(mappedName = "java:app/jms/myDestination", activationConfig =
    {
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic"),
        @ActivationConfigProperty(propertyName = "subscriptionDurability", propertyValue = "Durable"),
        @ActivationConfigProperty(propertyName = "clientId", propertyValue = "NewMessageBean"),
        @ActivationConfigProperty(propertyName = "subscriptionName", propertyValue = "NewMessageBean")
    })
    public class NewMessageBean implements MessageListener
    { 
    [...]
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how I can programmatically create a grid of squares. (each square
Does anyone know how I can Dynamically create an installation package that installs files
Does anyone know of any software that can be used to create Agile User
I know I can use Request.Browser.IsMobileDevice . But does anyone know how it works,
Does anyone know of a php class that can create/export ePub files? I have
Does anyone know if you can create a settings bundle that uses a UIButton?
Does anyone know how can I create a pop-up message box in server side,
Does anyone know how I can: create IP security policy manage IP filters and
Does anyone know if I can create an HTML Form to search the DHL
Does anyone know if I can create wall posts with html content using facebook's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.