Home
About Us
Download
Information
Components Repository
Sandbox Components
Jakarta Community
Project Docs
|
Introduction
|
Proposed by : James Strachan
Messenger는 웹서비스와 웹어플리케이션 안에서 JMS (Java Message Service)를 쉽게 사용할 수 있도록
만드는 JMS프레임워크이다.
메신저는 JMS API의 복잡성의 많은 부분을 간단한 facade API뒤로 감출 수 있게 한다.
더하여 메신저는 XML 설치 설정을 제공하여 당신의 어플리케이션 코드안에 복잡한 설치 설정사항들로 당신의 코드가 어지럽혀 지는 것을
피하도록 한다.
메신저는 또한 MessageListener들,또는 서블릿들 또는 JSP를 경유하는 JMS메세지들을 처리하는 어떤 서블릿엔진에서도 설치될수
있는 JMS기반 컨테이너인 Messagelet 엔진을 제공한다.
|
|
Messagelets
|
메신저 프로젝트는 Tomcat4.0 등등의 어느 서블릿엔진에서도 달리는 JMS기반 컨테이너인 Messagelet엔진을 제공한다. Messagelet
엔진은 JMS 메세지리스너들, 서블릿들 또는 심지어 JSP까지도 사용하는 방대한 방법으로 JMS 메세지들을 처리하기 위한 간단한 프레임워크를
제공한다.
Messagelet 컨테이너를 설치하기 위하여you need to add the ManagerServlet in a web application
giving it an XML configuration file describing all the various JMS connections
and an XML configuration file describing all the subscriptions.
Here are example
connections
and
subscriptions
XML configuration files.
There now follows the section you need to add to your web.xml configuration file to deploy the
Messagelet Manager Servlet.
 |
 |
 |
 |
<servlet>
<servlet-name>managerServlet</servlet-name>
<servlet-class>org.apache.commons.messagelet.ManagerServlet</servlet-class>
<init-param>
<param-name>connections</param-name>
<param-value>/WEB-INF/Messenger.xml</param-value>
</init-param>
<init-param>
<param-name>subscriptions</param-name>
<param-value>/WEB-INF/subscriptions.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
|
 |
 |
 |
 |
Once you've done the above and the web application is started the Messagelet engine will
subscribe to the various JMS subscriptions and then dispatch JMS messages to the various
MessageListener objects, Servlets or JSP pages.
There are a variety of ways in which you can process JMS messages depending on your requirements.
-
A MessageListener is a standard JMS listener of messages.
-
A MessageDrivenObject is-a JMS MessageListener which has
extra servlet-based lifecycle methods just like a Servlet.
This allows
an MDO to know when its being initialised and when its being destroryed
and so do some resource management (such as creating or closing database
connections etc). Also on initialisation the MDO gets access to the
ServletContext so that it can read some initialization parameters from
the web application or perform web-app level logging and so on.
-
A MessengerMDO is-a MessageDrivenObject
but also provides a number of helper methods such as access to the Messenger to
which its listening, so that responses can be sent back to the originator of the message,
as well as access to the ServletContext and some logging helper methods.
-
A Servlet can be any GenericServlet or HttpServlet.
If the JMS message that is being dispatched is a TextMessage then the body of the message is
available via the ServletRequest.getReader() method, in the normal Servlet way.
Any output written to the ServletResponse.getWriter() will be converted into a TextMessage
and sent back to the originator.
All servlets and JSP pages have access to the originating JMS message and Messenger objects via
the "message" and "messenger" request attributes respectively.
-
A Messagelet
is a JMS specific Servlet, just like a HttpServlet is a HTTP specific Servlet. It
provides access to a Messagelet specific
MessageletRequest
and
MessageletResponse
to allow access to the JMS Message and the Messenger for sending replies.
-
A JSP page can be any piece of JSP, for example the standard JSP tag library can be used
to perform JavaScript, XPath, XSLT or SQL operations on the incoming message.
The request scope "message" and "messenger" attributes can be used to access the originating
JMS Message and Messenger objects.
There are some examples of an MDO, Servlet and Messagelet
here or
you can see example JSP
here
|
|
|