Skip to main content

How to start/stop MDB in glassfish App Server

12 replies [Last post]
chalava
Offline
Joined: 2008-03-13

Hi

I would like know Is there any way to start/stop the MDB's in glassfish server. But at the same i would like to put messages in to Queue.

Scenario: I am going to upgrade my MDB but i don't want to down my app server. i would like down the application only. but at the same time i am not going distrubing client to send messages to Queue even though application is down.

Please send me your suggestion with proper resolution.

Thanks
Nanda

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
whartung
Offline
Joined: 2003-06-13

Yea, the problem is two fold.

The "nice thing" about MDBs is that they are simply "automatic", you don't have to write any of the listener code necessary to mange the connection. In most use cases, that's a feature. Obviously in your case, it's not.

If you disable the queue itself, then your clients have nothing to connect to, which isn't what you want either.

You may want to try something potentially hacky.

Basically, I would modify the MDBs to look for some property (probably in the database) that can be changed on the fly.

When the property tells the MDB to "shut down", the MDB does a couple of things.

One, it starts rejecting messages. It simply doesn't accept them, rolling back the transcation.

And, two, it start sleeping a LONG time (like, say, 1 minute) for each message it recieves. This way it's not rejecting vast amounts of messages, but only 60/hour (multiplied by however many MDB instances you have).

You will have the issue of configuring your system to handle the rejections artfully (so that it doesn't dump them in to a dead letter queue, say).

But, it will effectively "kill" the MDB. I assume you simply want to delay processing, that's why you're disabling the MDB. When you want to reenable the MDB, reset your flag, and messages should start to flow again once your 1 minute timers start expiring.

It's not a particularly formal mechanism, nor elegant, but it should work.

It may also work where the MDBs don't reject messages at all, but simply never finish. They simply continually poll your global flag (again within a long sleep loop), and the JMS queue just sits there. You may get timeouts on this tho, I've never done it.

But I'd try both techniques to see which fits your needs better and smells better. :-)

chalava
Offline
Joined: 2008-03-13

Nice to see yr reply.. may be useful for me.

1. I don't want to stop MDB programatically.It shd be configured in Glassfish.
2. Is there any way to configure in glassfish Admin console or config files to disable MDB
3. Or Is there any external applications for glassfish to stop the MDB.

- thanku

whartung
Offline
Joined: 2003-06-13

Basically, no, it can't be done with GF currently. You might want to submit a feature request and perhaps they can roll this in to a future version of GlassFish, but for now there's no way to do this at the container level.

fatsu
Offline
Joined: 2009-02-10

Hi,

have you already come up with a solution for this problem?

It seems that jboss, websphere and oracle/weblogic use an mbean to achieve this functionality, but since changing app server is not an option, i'm kind of stuck.

Tom

openwms
Offline
Joined: 2009-03-12

Once I did something similar. You can use JMX to control the status of your configured JMS destinations. It is possible to start (resume) or stop (pause) a destination for receiving/sending or in both directions. Also you can fetch a list of all destinations and some other things. Just use JMX!

See: com.sun.messaging.jms.management.server.DestinationPauseType

or the list of possible operations:
com.sun.messaging.jms.management.server.DestinationOperations

example:
// obj = ObjectName of the destination
MyUtil.invokeOperation(obj, DestinationOperations.PAUSE, new Object[] { DestinationPauseType.ALL }, new String[] { String.class.getName() });

This is an app server independent solution and fits for GF2.1/2.1.1/3

whartung
Offline
Joined: 2003-06-13

Does the queue still continue to receive message, just not deliver them? As I read the original, I think user wants to continue to receive messages while the MDB is being redeployed, so as not to bother the clients.

lavkul
Offline
Joined: 2007-12-14

Hi,
Have you tried hot deployment? It may work?

-Lave

chalava
Offline
Joined: 2008-03-13

How it helps me hot deployment. how can i stop MDB to consume messages.

keep it mind i have couple of MDB's in my applciation. i would like to stop consuming only one MDB.

thanku.

whartung
Offline
Joined: 2003-06-13

Have you tried simply undeploying you application? Does that work?

The JMS queue associated with your MDB is part of the server, not your application. So Ideally it should remain up even if you application in undeployed.

Mind, if you don't have persistent subscriptions, all of your data in the interim will be lost, but that's a different issue.

chalava
Offline
Joined: 2008-03-13

thanx for the reply...

i would like to stop consuming messages. i don't want to undeploy the application. at the same time i am sending messages to Queue.

is there any other solution?

thanx

rampsarathy
Offline
Joined: 2005-11-23

the only other (similar) solution would be disabling the entire application (java ee module / ear). Even in this case all the other entities (servlets/EJBs) that are present in your app will be disabled.
If you have deployed your MDB as a separate java ee jar module then disabling/undeploying would work, but if you want to selectively stop consuming only in the MDB then there is no way ASFAIK.
Maybe there is someway you could configure the queue/topic at the broker end to do this.

chalava
Offline
Joined: 2008-03-13

If i disable the application as you said it will disable all MDB's in the application.
But i have like 3 MDB's in the application. Is it posible to diabale one MDB.

And also i have tried in Queue/Topic end, when i pause the Queue/Topic below thing are happening.
1. Consumer not able to receive any messages from Queue/Topic( which i want),
2. At the same time queue also not able receive any messages from client.

I don't want the second statement to be happened. I want to first
statement to be happened.

thanku.