• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

how to use two execute queues for one servlet

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

is it possible to use two execute queues for the same servlet.

for eg: i have only one servlet A , which can process two types of requests. i would like to pass first kind of request to one execute queue(probably default execute queue weblogic.kernel.Default) and second type of request to second excute queue.

Please help me !

Thanks
Sudhakar
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does it mean "two kinds of requests"?
If, for example, the difference is in the url pattern you can declare two different servlets with the same class as below :

<servlet>
<servlet-name>A</servlet-name>
<servlet-class>com.blablabla.XServlet</servlet-class>
<init-param>
<param-name>wl-dispatch-policy</param-name>
<param-value>firstExecuteQueue<param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>B</servlet-name>
<servlet-class>com.blablabla.XServlet</servlet-class>
<init-param>
<param-name>wl-dispatch-policy</param-name>
<param-value>secondExecuteQueue<param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>A</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>B</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>

Hope it helps...

Best regards
 
Andrea Gazzarini
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excuse me for the format...



Hope it helps...

Best regards
 
sudhakar papireddy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Andrea Thank you for your reply.

let me explain the scenario.

when ever there is request to servlet, in the request object we have parameter called BEAN. servlet reads this parameter from the request object and create a object for with that parameter
eg: //Here WBean is a generic Bean
WBean wb = null;
String targetName = (String)request.getAttribute("Bean");
wb = (WBean)beanFactory.createObject(targetName);

Than it is going to call the following function to process the request.
wb.processRequest(request, response ,beanFactory).

Currently we divided these beans into to two categories. One set of beans is for saving data and another set of beans is to retrieve the data.
by default all these requests are going through the default web logic queue.


so we are planning to send the request to default queue if it is for saving the data (first category).
Otherwise send the request to another queue(new execute queue)( second category).

can you please help us , whether we can setup two execute queues in this scenario.

Thanks
sudhakar
 
Andrea Gazzarini
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sudhakar, simply : you can't do that with your actual design!

The container is not able to make a distinction between two requests with the same url pattern.
This is your scenario : you are calling the same servlet using a different value for a request parameter :

http//host ort/app/servlet?BEAN=A
http//host ort/app/servlet?BEAN=B

what is written after the name of the servlet is called the query string and is not part of
the identifier used in the url-pattern declaration.

now, since your bean are (I suppose) normal POJO, there's no container interposition so
after a thread is executing your servlet you can't ask to the container another thread for executing a POJO.

Here's one suggestion:

1) Take the value of the BEAN parameter and create a jms TextMessage with it;
2) Create a temporaryQueue (ex: incomingResponseQueue)and send the message to a previously declared jms queue (ex: incomingRequestsQueue) with the setJMSReplyTo property set to the temporary queue;
3) An MDB detaches the message from the incomingRequestQueue, takes the name of the bean and create a valid instance using the ObjectFactory.
4) The MDB executes the bean and send the response as a ObjectMessage to incomingResponseQueue.
5) The servlet consume the message from the incomingResponseQueue.

Something like this:

***** Servlet code ******



**** MDB CODE ****



now, you have solved the first part of the problem : you can execute your beans in a separated executing thread.
How you can distinguish the bean for updating and for retrieving data?

1) You can deploy twice the MDB (with two different names) on two different jms queues and assign to each of them a different execute queue.
This could be done with some kind of configuration in the web.xml. (for example a mapping between bean name --> destination Queue)
In this way the servlet must act as a router / dispatcher between the two queues / MDB.

2) If the names of the beans follow some kind of naming convention and starting from the name you can understand the category of it
you can deploy twice the MDB (with two different names) on THE SAME jsm queues and assign to them a corrispondent message selector.
In this way the servlet must put the bean name also in a string property of the jms message.


Best regards
 
sudhakar papireddy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi thanks for your reply.

here i am confused about the last part
-------------------------------------------------
How you can distinguish the bean for updating and for retrieving data?

1) You can deploy twice the MDB (with two different names) on two different jms queues and assign to each of them a different execute queue.
This could be done with some kind of configuration in the web.xml. (for example a mapping between bean name --> destination Queue)
In this way the servlet must act as a router / dispatcher between the two queues / MDB.

2) If the names of the beans follow some kind of naming convention and starting from the name you can understand the category of it
you can deploy twice the MDB (with two different names) on THE SAME jms queues and assign to them a correspondent message selector.
In this way the servlet must put the bean name also in a string property of the jms message.
----------------------------------------------------------------

can you explain little bit more about this (specially point 1 )
 
Andrea Gazzarini
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
suppose you have four beans. A,B,C,D. A and B are for retrieving data, while B and C for updating. Well, as I wrote you have two choices :

1) Using servlet deployment descriptor. Using init params you must declare inside the Deployment descriptor all the beans divided by category. Something like this:


Now, you servlet looks like this:



2) Using message selector.
In this scenario you have only one queue and two MDB. The first MDB (for updating) has a message selector like this :

beanName IN ('A','B')

while the second one (for retrieving data) has the following message selector:

beanName IN ('C','D')

Now your servlet doesn't need to know the kind of request so in your service / doGet / doPost method :



That's all...the container will route the message to the appropriate MDB (using the message selector).

Regards
 
sudhakar papireddy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Andrea
Thank a lot for your info.


---------------
Thanks
Sudhakar P.
 
reply
    Bookmark Topic Watch Topic
  • New Topic