ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » MQContext to setup JMS through code rather than JMSAdmin?

Post new topic  Reply to topic
 MQContext to setup JMS through code rather than JMSAdmin? « View previous topic :: View next topic » 
Author Message
JohnRodey
PostPosted: Wed Jul 13, 2005 9:24 am    Post subject: MQContext to setup JMS through code rather than JMSAdmin? Reply with quote

Centurion

Joined: 13 Apr 2005
Posts: 103

Does anyone know if there is a way to set up your JNDI settings on a queue manager using mqcontext.jar (from the me01 support pac) through code, not JMSAdmin.

We want to be able to create queues on the fly which we can do using pcf messages, then set up the new queues JNDI settings. This is possible by calling a script that would call JMSAdmin, although we would like to escape making system calls, and do this action more generically through straight java code.

Can anyone point me to an example of how to do this?
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jul 13, 2005 9:51 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You probably want to look at the documentation for using JMX with WAS.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Jul 13, 2005 4:40 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

If the queues are temporary and not permanent you should look into the Context API. You should be able to bind and remove objects.

As for creating queue you don't have to use pcf. You can use the JMS api to create a temporary queue or a permanent queue. However you need a model queue as base queue.

Enjoy
Back to top
View user's profile Send private message Send e-mail
vennela
PostPosted: Wed Jul 13, 2005 8:01 pm    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

Also, you can build your JNDI queues on the fly. This is much more powerful way than anything else. You don't need any support pac for this.
Look at the using Java Manual for more information

http://www.mqseries.net/phpBB2/viewtopic.php?t=18496&postdays=0&postorder=asc&highlight=uri%20jndi&start=15
Back to top
View user's profile Send private message Send e-mail Visit poster's website
JohnRodey
PostPosted: Fri Jul 15, 2005 7:48 am    Post subject: Reply with quote

Centurion

Joined: 13 Apr 2005
Posts: 103

I tried creating a queue with the Context class, although It would not create the queue on my QM. Oddly enough though I was able to create a temporary queue. Currently I am using the .bindings file.

Here's a snippet of my code:

ctx = new InitialContext(props);
qConFactory = (QueueConnectionFactory)ctx.lookup("myQCF");
qCon = qConFactory.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);

Queue q = qSession.createTemporaryQueue();
//works! It is viewable on my QM

//Queue q2 = qSession.createQueue("YQUEUE"); <- this returns queue:///YQUEUE,and does not show up on my QM

Queue q3 = qSession.createQueue("queue://my.queue.manager/ZQUEUE"); //this also does not show up on my QM


Has anyone tried this? (with or without success)
I'm also having problems using the ctx.addToEnvironment("Z", q3);
It always returns null.
but that my be due to the above issues.

Thanks for any help
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Jul 15, 2005 7:52 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

There's no connection between the JMS/JNDI definition and the queue definition.

So in order for both to exist, you have to write separate code to define both.

But what are you actually trying to do?

Automate the creation of JMS resources as part of application deployment?

Or create and then use queues on the fly from within an application?

If the former, then you should use JMX to create the JNDI resources and PCF to create the queue resources.

If the later, then you should use a temporary queue - as you are already able to do.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
JohnRodey
PostPosted: Fri Jul 15, 2005 10:42 am    Post subject: Reply with quote

Centurion

Joined: 13 Apr 2005
Posts: 103

Thanks Jeff

We are using your first scenario, generate queues and the jndi settings for automating setup.

Currently we are using pcf to create queues, so that isn't much of a problem.

So I guess I have two questions...

1) Can ctx.addToEnvironment() not be used???

2) I am not familiar with JMX, is it dependent on an app server? We do not own a license to WAS and do not plan on using an app server. If JMX is independent of WAS then would you possibly be able to point me to an example of how to use JMX to setup JNDI settings.

Thanks
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Sun Jul 17, 2005 2:40 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

So, you're trying to automatically create a file system context?

Yes, I was assuming you were trying to create resources inside an app server.

I don't know anything about creating file system contexts, sorry. JMX likely won't be much good then.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
JohnRodey
PostPosted: Mon Jul 18, 2005 4:41 am    Post subject: Reply with quote

Centurion

Joined: 13 Apr 2005
Posts: 103

Has anyone tried creating the JNDI settings through JMS on the fly?
something like this:

ctx.addToEnvironment("MYQUEUENAME", queue);

I have tried this using a .bindings file as well as and LDAP, but with no luck either way.

Has anyone had any success with this?
Is this possibly a method that IBM has never implemented? Maybe they just put a stub in their jms.jar
Back to top
View user's profile Send private message
JohnRodey
PostPosted: Mon Jul 18, 2005 6:34 am    Post subject: Reply with quote

Centurion

Joined: 13 Apr 2005
Posts: 103

I haven't tested it totally yet but I think I figured it out.

If you wish to add a queue into your JNDI context, you must use the ctx.bind("NAME", Queue) call. Not sure exactly what the addToEnvironment does?

thanks for all of your help
Back to top
View user's profile Send private message
JohnRodey
PostPosted: Mon Jul 18, 2005 9:11 am    Post subject: Reply with quote

Centurion

Joined: 13 Apr 2005
Posts: 103

Just to help out anyone who has a future issue like this.

I believe addToEnvironment is used to set context properties after your context has been created. You might need to do this for LDAP if you have security set.

ctx.addToEnvironment(Context.SECURITY_AUTHENTICATION, "simple");
ctx.addToEnvironment(Context.SECURITY_PRINCIPAL, "cn=myusername");
ctx.addToEnvironment(Context.SECURITY_CREDENTIALS, "mypassword");
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » MQContext to setup JMS through code rather than JMSAdmin?
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.