Built-in Glassfish and `imqcmd`
We are using the built-in Glassfish server in our test environment. We use an interface
to perform administrative tasks (that is, what we do with
a standard standalone Glassfish server)
GlassFish glassfish = GlassFishRuntime.bootstrap( bp ).newGlassFish( gfp ); CommandRunner commandRunner = glassfish.getService( CommandRunner.class ); commandRunner.run( "create-jms-resource", "--restype", "javax.jms.Queue", "SOME_QUEUE_NAME" );
Now on the command line, I can set the queue parameters with
. for example
imqcmd -u admin -passfile ../password.txt update dst -n SOME_QUEUE_NAME -t q -o maxBytesPerMsg=-1 -f
Is there a way to achieve the same with the built-in Glassfish server?
source to share
Instead of using it,
you can use a subcommand
to create a physical JMS destination.
From the documentation in
Typically, you use a subcommand
to create a JMS destination resource that has a Name property that specifies the physical destination. The physical object is created automatically when the application starts using the target resource. Use this subcommand
if you want to create a physical target with custom property settings.
If you do not specify the Name property for
, the name of the physical target will have the same name as the target resource (replacing any forward slash in the JNDI name with an underscore).
Thus, the commands
you want to run are for example:
create-jms-resource --restype javax.jms.Queue org/example/foo/SomeQueue create-jmsdest --desttype queue --property maxBytesPerMsg=-1:maxTotalMsgBytes=-1 org_example_foo_SomeQueue
Note that (unlike
imqcmd update dst
does not update properties if the resource already exists. Therefore, you should not run your application between two commands, otherwise the resource is automatically created with default properties.
If you need to update the properties, you can first remove the physical address, using, for example
asadmin delete-jmsdest org_example_foo_SomeQueue
source to share