Built-in Glassfish and `imqcmd`
We are using the built-in Glassfish server in our test environment. We use an interface org.glassfish.embeddable.CommandRunner
to perform administrative tasks (that is, what we do with asadmin
a standard standalone Glassfish server)
Example:
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 imqcmd
. 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, imqcmd
you can use a subcommand asadmin
create-jmsdest
to create a physical JMS destination.
From the documentation in create-jmsdest
:
Typically, you use a subcommand
create-jms-resource
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 subcommandcreate-jmsdest
if you want to create a physical target with custom property settings.
If you do not specify the Name property for create-jms-resource
, 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 asadmin
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
) create-jmsdest
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