Java Message Service FAQ From Jguru
Java Message Service FAQ From Jguru
Location: http://www.jguru.com/faq/JMS
Ownership: http://www.jguru.com/misc/user-agree.jsp#ownership.
What is JMS?
Location: http://www.jguru.com/faq/view.jsp?EID=772
Created: Nov 10, 1999 Modified: 1999-11-10 16:20:17.574
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
Java Message Service (JMS) is a specification for message passing and related
operations among distributed software components. JMS vendors implement the
specification, providing the requisite API library, plus a broker, or server, that handles
message passing among clients. Programmers then implement applications that
communicate with each other by way of the vendor's JMS software.
Yes. Prior to JMS, Java software for various distributed computing environments, for
example, the WebLogic server, the Aglet framework for mobile agents, SoftWired's
iBus software, and many others have provided a variety of message-oriented,
interclient communication solutions for enterprise computing. In many cases, the
messaging functionality is part of a larger distributed computing framework.
There are several reasons. First, the JMS specification includes two popular
messaging strategies: point-to-point and publish/subscribe. Many vendors are
supporting this common framework; hence, programmers will be able to implement
message-oriented operations in their distributed software that will be portable across
many messaging-oriented middleware (MOM) products.
Fourth, although the JMS specification does not require a security-related API, many
JMS implementations provide extensive built-in security. Messages can be
transmitted using certificates, as well as encryption. JMS implementations free the
developer from many security burdens associated with distributed computing
because JMS applications work through the JMS server, which provides security
through administered objects. That is, beyond the application, it's possible to
establish topic- and queue-based security controls for users, groups, access lists, and
so on.
JMS can be an important tool for both e-commerce and e-business applications. Any
enterprise computing strategy that calls for middleware solutions that function as
glue and/or communication pathways among legacy applications is a potential
candidate for JMS-based distributed software components. It is straightforward to
write distributed components, for example, Enterprise JavaBeans that interface with
legacy applications. These legacy-software-managing Enterprise JavaBeans can send
legacy-related data among themselves via JMS middleware.
JMS
Author: Gopesh Khandelwal (http://www.jguru.com/guru/viewbio.jsp?EID=810100),
Mar 24, 2002
Could you give me some real life examples where JMS can be utilized.
Does JMS require the Java Naming and Directory Interface (JNDI)?
Location: http://www.jguru.com/faq/view.jsp?EID=778
Created: Nov 10, 1999 Modified: 1999-11-10 16:23:38.421
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
No, but... JNDI provides network-oriented look-up services for distributed objects
(among other things). It's possible to implement, as well as use, JMS software
without JNDI. In general, however, JNDI provides critical services for JMS-based
software because it's important to be able to locate (programmatically) JMS services
implemented in objects called factories.
For example, applications that communicate via JMS must set up communication
pathways that involve destinations (topic areas and queues), connections, sessions,
and so on. JNDI makes it easy for an application to locate, for example, a connection
factory for the appropriate vendor's JMS middleware, which can then provide a
connection, which can provide a session, and so on, all relative to the JMS server
that's associated with that connection factory.
Also, without this intermediary, the sending client would have the burden of
monitoring whether or not the receiving client is currently connected, whether or not
a network failure occurred during the send operation, and so on. The server plays an
important role in transparently handling many network-related issues, including
reliable message delivery, which can require transaction processing and/or persistent
message storage.
Does JMS provide load balancing, fault tolerance, scalability, and so on?
Location: http://www.jguru.com/faq/view.jsp?EID=780
Created: Nov 10, 1999 Modified: 1999-11-10 16:25:42.231
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
The JMS specification does not address these issues; hence, vendors are free to
implement their own support, and many vendors do provide these services.
The answer depends on your point of view. From one point of view, nothing is
missing. In terms of common distributed computing-related functionality, typically
present in larger Java application servers, JMS does not mandate functionality
related to the following:
• Administration
• Error, or system event, notification
• Load balancing, scalability
• Low-level transport protocol
• Security
The "J" in JMS stands for Java, so the first prerequisite is a Java development and
runtime environment.
Third, if not provided by the existing distributed computing software, you must have
a JMS implementation. Note that some Java application servers include JMS; hence,
they provide virtually seamless access to JMS functionality.
And, of course, distributed applications can use JMS message passing directly, or
develop a higher-level, enterprise-specific framework on top of JMS.
The JMS site at Sun is a good starting point. The vendors' page points to several
sites and many of the vendors provide whitepapers and tutorials.
The JMS site at Sun provides links to the specification, as well as the online javadocs
for JMS.
Where can I find a short introduction to JMS, including code segments and
example programs?
Location: http://www.jguru.com/faq/view.jsp?EID=786
Created: Nov 10, 1999 Modified: 2000-03-20 11:07:14.117
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
Does the specification require that all JMS implementations provide both
point-to-point and publish/subscribe messaging?
Location: http://www.jguru.com/faq/view.jsp?EID=787
Created: Nov 10, 1999 Modified: 1999-11-10 16:29:23.702
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
No. Many JMS implementations provide both, but the specification defines
compliance for each messaging style separately.
With JMS, distributed components interact with the JMS broker via destinations
(topics and queues), which then disseminates messages to the registered clients;
thus, distributed components do not have to know (and manage) each others'
network locations. As for the JMS middleware, it can use (behind the scenes) any of
several network topologies, for example, bus, ring, hierarchical, fully connected
(peer-to-peer), star (hub-and-spoke), or others, including hybrids.
Messaging systems are peer-to-peer distributed systems in the sense that, at least
potentially, every (registered) client can communicate with every other (registered)
client.
What are the core JMS-related objects required for each JMS-enabled
application?
Location: http://www.jguru.com/faq/view.jsp?EID=791
Created: Nov 10, 1999 Modified: 1999-11-10 16:31:04.376
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
JMS messages include a header, properties, and the message body. Headers provide
identifying and routing information. Properties allow arbitrary ornamenting of
messages with application-specific markers or tags. Receiving clients can select, or
filter, messages based on properties.
To obtain a message of the requisite type, make a request via the appropriate create
method, for example:
These terms are sometimes used interchangeably. Note, however, that, technically, a
JMS implementations is any implementation of the JMS API. Thus, an arbitrary
collection of application components could implement the JMS interfaces, and then
provide messaging services to its peers. The term provider is quite general and
typically would be interpreted as any implementation that provides complete JMS
functionality, with either publish/subscribe or point-to-point messaging, or both.
Technically, a JMS broker could be, perhaps, any implementation of the messaging
brokering services, omitting, for example, certain administrative capabilities.
Although the term broker is common, its usage may require a contextual
interpretation. In some cases, the entire JMS implementation/server is referred to as
a broker; in other cases, broker is used at the destination level. For example, if the
JMS server is managing the topic "Java" (among others), the "Java" topic is a broker
for all messages published to "Java" and distributed on to "Java" subscribers.
There are two possible domains in JMS: (1) the publish/subscribe domain and (2) the
point-to-point domain. Not all JMS implementations provide both domans.
With the point-to-point domain, clients interact via a message queue. With the
publish/subscribe domain clients interact via a node in a content hierarchy, each
node representing a topic, or subtopic.
The act of serving, like beauty, is in the eye of the beholder. Any application that
provides services to another application is a server. The JMS message broker
provides both direct and indirect services:
Applications that connect to and use the JMS broker are its clients.
From another point of view, any number of distributed application components can
use JMS for interclient communication. Thus, these (JMS broker) clients are actually
peers to each other, that is, with respect to the distributed applications scenario. In
this case, each peer is potentially a client to and a server for other peers.
The JMS specification does not require a security-related API and it does not address
in detail the process/mechanism for administering objects that exist within a running
JMS implementation. Thus, the administration process differs across vendors.
• Destination
• ConnectionFactory
• Connection
Sessions are single-threaded contexts because a session is where the action is. In
particular, a session is responsible for operations such as transaction handling and
asynchronous message passing. Requiring client code that's related to asynchronous
message reception to support concurrent use would have been especially
burdensome.
Note that clients can use multiple sessions to partition client operations. For
example, one client thread can drive one session and another client thread can drive
another session. Each session object serializes execution of message listeners (the
methods that handle asynchronously delivered messages). Thus, message listeners
(handlers) can share session-related resources. Client resources (critical objects)
outside the session, however, are the responsibility of the application designer, as
always.
The JMS specification does not require support for topic hierarchies. Although topic
hierarchies can be a powerful tool, it's important to consider whether or not
portability is an issue. Topic hierarchy designs vary across JMS servers, and not all
JMS servers implement topic hierarchies.
Is it possible for a client to send multiple messages and ensure that the
entire set of messages is delivered?
Location: http://www.jguru.com/faq/view.jsp?EID=1147
Created: Nov 19, 1999
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
Each client can create multiple sessions, with each session producing and/or
consuming messages. Each session is independently configurable. (Note that each
session should be closed gracefully to free server resources.)
No. It is possible (if provided by the JMS implementation) to use JTA in the context of
a session, but not a transacted session. That is, you cannot use Session.commit()
and Session.rollback() in a context that's controlled by an instance of
UserTransaction.
If, for example, one or more messages, in conjunction with database operations, all
form a "logical transactional unit," it's usually best to take advantage of the
transaction support provided by the JDBC driver, possibly augmenting this transacted
(database) server operation with, javax.transaction.UserTransaction from the
Java Transaction API (JTA), if JTA is implemented by the JMS server. Note that JMS
implementations vary in their support for distributed tranaction processing. See the
javax.jms.XA... interfaces in the API documentation.
The JMS spec allows for (optional) support of the JTA. Notably, a JMS Connection
can provide an XAResource, which controls an XASession, for the transactional
delivery or receipt of messages.
No. A client, in a single operation, cannot publish to a list of topics and it cannot send
to multiple queues. A client must establish a message-producer object for each
topic/queue and manually publish/send to each destination.
Can a client (a publisher) detect whether or not there are subscribers to a
topic?
Location: http://www.jguru.com/faq/view.jsp?EID=1151
Created: Nov 19, 1999
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
And, of course, if messages are published to a topic via multiple sessions, there is no
way to guarantee the ordering of message delivery because each session (potentially
driven by different threads of execution) is subject to different scheduling and
performance variances.
Distributed transaction services are provided via the Java Transaction API (JTA). JMS
does not mandate JTA support. See the JMS vendor's documentation for JTA-related
discussion, especially, whether or not the vendor supports JTA.
What are the ramifications of having multiple consumers in one session for
the same destination (queue or topic)?
Location: http://www.jguru.com/faq/view.jsp?EID=1154
Created: Nov 19, 1999
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
The JMS server will provide only one instance of each message for a named
destination per session. The issue of which consumer actually receives the message
is implementation dependent. There is no reason to (ab)use a session in this
manner!
In JMS1.0.1, only one (random) MessageListener would receive the Message. As this
was found to be severely limiting for certain applications, in JMS1.0.2 all the
MessageListeners will receive the Message.
It's convenient to view persistent and nonpersistent messages from the same
producing client as elements of a partitioned space, even if sent to the same
destination. There is no guarantee that a consuming client will even receive a
nonpersistent message; hence, nonpersistent messages must be exempt from any
logical conditions on message order in the producing client.
A related issue is that, at best, messages are only ordered within each message-
producing session by destination.
Message priority is another related factor. In general, messages with higher priority
will arrive before messages of lower priority, within a session, but it is not possible to
depend on high-priority nonpersistent messages being delivered before low-priority
persistent messages.
Can a publishing client ensure the order of message deliver for, say, five
messages, by manipulating the priority of each message from, say, 5 to 1?
Location: http://www.jguru.com/faq/view.jsp?EID=1157
Created: Nov 19, 1999
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
No. Message priority is considered by the JMS server and potentially overrides the
default first-in-first-out (FIFO) message handling strategy. Priorities should be
viewed as one factor that potentially affects the order of message delivery.
The recommended way to ensure the order of message production and reception
between the publisher and the consumer is with a transacted session.
As a JMS server receives messages from producing clients and evaluates which
consuming client(s) it should forward each message to, the server applies a
consumer's selector to data in the message header. Messages that do not meet the
selection criteria are not delivered to the consumer. A message selector uses SQL92
condition syntax, for example,
session.createReceiver(queue,
"DogBreed in ('Newfoundland', 'Mastiff')");
The "data" for selection criteria include certain message header fields, as well as
properties attached to messages.
There are at least three reasons. First, in most cases, client-side filtering is quite a
burden to implement, for example, parsing a textual message. Second, if the
message type were, say, Object, it could be burdensome for the producer to
"decorate it" with selection criteria and/or for the consumer to select messages
based on those criteria. Third, using a selector is more efficient because the JMS
server avoids having to send the filtered message to the consumer.
No! Or, yes--by not sending messages that it doesn't want to send! Message filtering
is consumer-oriented.
Message producers can attach arbitrary properties to outgoing messages. This data
is stored in the message header, in essence, as virtual fields in the header. JMS
reserves the "JMSX." property name prefix for JMS-defined properties.
• DUPS_OK_ACKNOWLEDGE
• AUTO_ACKNOWLEDGE
• CLIENT_ACKNOWLEDGE
See the JMS API documentation, in particular, the description for Session, for
complete message acknowledgment information.
No. You must set up a message listener implementation for asynchronous message
consumption.
For "on-the-fly, programmatic realizations" that you need a heretofore unanticipated
message listener, you could probably design and define in advance a generic one-
size-fits-all class that implements MessageListener.
If a client registers multiple message listeners for a given session, are the
listeners processed concurrently?
Location: http://www.jguru.com/faq/view.jsp?EID=1166
Created: Nov 19, 1999
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
No. Each session uses a single thread of execution to handle registered listeners;
thus, listeners are serviced one at a time--all listeners except for the one being
serviced are waiting.
If the JMS server experiences a failure, for example, a power outage, any message
that it is holding in primary storage potentially could be lost. With persistent storage,
the JMS server logs every message to secondary storage. (The logging occurs on the
front end, that is, as part of handling the send operation from the message
producing client.) The logged message is removed from secondary storage only after
it has been successfully delivered to all consuming clients.
No! The reason for supporting both nonpersistent and persistent messages is to
assist the programmer in balancing the trade-offs for guaranteed, reliable delivery
and its inherent overhead for the JMS server versus the lower-overhead, no-
guarantee delivery.
What are the criteria for choosing the point-to-point messaging model over
the publish/subscribe model, and vice versa?
Location: http://www.jguru.com/faq/view.jsp?EID=1175
Created: Nov 19, 1999
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
When a subscribing client (via it session with the JMS server) requests a durable
subscription, the JMS server will "save" any messages intended for the subscriber
during periods when the subscriber is inactive.
Comments and alternative answers
"At the cost of higher overhead, a subscriber can be made durable. A durable
subscriber registers a durable subscription with a unique identity that is retained by
JMS. Subsequent subscriber objects with the same identity resume the subscription in
the state it was left by the prior subscriber. If there is no active subscriber for a
durable subscription, JMS retains the subscription's messages until they are received
by the subscription or until they expire."
The next time the client reconnects, it must provide the same client ID and durable
subscription name, in order to receive any accumulated messages that have been held
for the client ID/subscription name combination.
Re: Ok, now I understand the JMS Spec. The procedure is...
Author: Tim Rickard (http://www.jguru.com/guru/viewbio.jsp?EID=454468), Jul
13, 2001
I am confused on this point myself. If I 'reconnect' with a different selector and
messages have been stored for the clientid/username pair that dont meet that
selector, are they tossed by the system.
Is there a method that allow pub to specify which subscriber to get the message?
Author: steeven lee (http://www.jguru.com/guru/viewbio.jsp?EID=572247), Dec 4,
2001
Is there a method that allow pub to specify which subscriber to get the message? In
durable mode, the subscriber has provide an unique ClientId to tell from other
subscriber. so when the server get a message that specified which ClientId should read
the message, the sever should send the message to only the ClientId other than
broadcast it out to every subscriber of the topic. an filter will do the same thing, but it
is Seted by client, not from the sender, the sender should has the ability to decide
where the message should be send.
Durable versus nondurable relationships exist between a consuming client and the
JMS server, which delivers messages. Persistence versus nonpersistent delivery mode
involves a message-level relationship established between the producing client and
the JMS server, and only indirectly between the producing and consuming clients.
A producing client can choose persistent delivery mode for either messaging model,
publish/subscribe or point-to-point. "Durable delivery" is an option for clients that
subscribe to topics, not for clients that connect to a queue.
In the section "Topic Management" the JMS specification states: "JMS does not define
facilities for creating, administering, or deleting topics." In the JMS API, however, the
QueueSession and TopicSession interfaces include createQueue() and
createTopic(), respectively.
For now, it's likely that JMS implementations will vary with respect to static versus
dynamic topic creation, as well as external topic administration and manipulation. It's
possible that some implementations will require static topic creation in advance using
external functionality, for example, a utility. Some JMS implementations include a
complete system administration tool for topic and queue management. Some
implementations will provide administrative APIs for programmatic control of
resource management. Other implementations may provide basic facilities for, say,
topic or queue creation on the fly, plus an administrative console for creation,
deletion, and other management tasks, plus security management.
For example, some environments support dynamic look-up using JNDI, plus dynamic
destination creation, if necessary:
...
try {
queue = (Queue) c.lookup(QUEUE);
}
catch (NamingException ne) {
try {
queue = session.createQueue(QUEUE);
c.bind(QUEUE, queue);
}
catch (Exception e) {
readyToSend = false;
closeConnection();
return;
}
}
...
In the previous code segment, c is a JNDI InitialContext object.
Client implementations vary with respect to set-up operations, depending on the JMS
implementation. The following client, ObjectReceiver, works with the WebLogic Java
application server, which supports JMS:
import javax.jms.*;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Hashtable;
private Context c;
private QueueConnectionFactory qcf;
private QueueConnection con;
private QueueSession session;
private QueueReceiver receiver;
private Queue queue;
private boolean quit = false;
private boolean readyToReceive;
public ObjectReceiver() {
this(SERVER_URL);
}
Client implementations vary with respect to set-up operations, depending on the JMS
implementation. The following client, ObjectSender, works with the WebLogic Java
application server, which supports JMS:
import javax.jms.*;
import java.io.Serializable;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
private Context c;
private QueueConnectionFactory qcf;
private QueueConnection con;
private QueueSession session;
private QueueSender sender;
private Queue queue;
private ObjectMessage msg;
private boolean readyToSend;
public ObjectSender() {
this(SERVER_URL);
}
Clarification required
Author: Johnson Samuel (http://www.jguru.com/guru/viewbio.jsp?EID=561793), Nov
26, 2001
Exception in thread "main" javax.naming.CommunicationException. Root exception
is weblogic.socket.UnrecoverableConnectException: [Login failed: 'Incompatible
version:Incompatible versions - this server:6.1.0.0 client:5.1.0] this is the error i am
getting clarification regarding this is appreciated
Client implementations vary with respect to set-up operations, depending on the JMS
implementation. The following client, TimeSubscriberSonicMQ, works with the
SonicMQ JMS server:
import javax.jms.*;
public TimeSubscriberSonicMQ() {
this(SERVER_URL);
}
Client implementations vary with respect to set-up operations, depending on the JMS
implementation. The following client, TimePublisherSonicMQ, works with the
SonicMQ JMS server:
import java.util.Date;
import javax.jms.*;
//
// main() is for testing only. It starts time publishing, waits
// for a short period of time, and then stops time publishing.
//
public TimePublisherSonicMQ() {
this(SERVER_URL, REPORTING_INTERVAL);
}
• Implement javax.jms.MessageListener:
• public interface MessageListener {
• void onMessage(Message message);
• }
• Register the message handler using setMessageListener():
• ...
• subscriber = session.createSubscriber(topic);
• SubscriberMessageThread smt = new SubscriberMessageThread(this);
• subscriber.setMessageListener(smt);
• con.start(); // start connection
• smt.start();
• ...
The use of a listener for method notifications is similar to using listeners for event
notification with graphical AWT clients. Note, however, that every AWT application
has a screen-updater thread running in the background that keeps the application
alive when main() completes its thread of execution. Certainly, JMS clients vary
enormously in function but, in general, some thread of execution must be
responsible for managing the wait cycle associated with potential onMessage()
invocations.
Again, clients vary in many ways, but one strategy is to design either a general-
purpose class to handle this task, which can be specialized for each message-
receiving scenario, or build this functionality into the client itself (the client
implements MessageListener). In the first case, you could design a simple class that
extends Thread and implements MessageListener, for example, MessageThread:
public MessageThread() {
super();
}
Note that onMessage() is empty. Hence, for each message-receiving scenario, you
could specialize this class providing the appropriate functionality for onMessage.
(See, for example, the reference to SubscriberMessageThread in the previous code
segment from the JMS client that registers the message handler.)
Note that some JMS implementations provide convenience functionality for handling
the wait process, for example, ThreadHelper.WAIT_UNTIL_EXIT.suspend(), in
iBus//MessageServer.
JMS
Author: giordano bruno (http://www.jguru.com/guru/viewbio.jsp?EID=1223061), Jan
24, 2005
what is this
SubscriberMessageThread smt = new SubscriberMessageThread(this);
Re: JMS
Author: l h (http://www.jguru.com/guru/viewbio.jsp?EID=1251056), Jun 30, 2005
Looks like that's an error. Check this link out.... this example works.... I tried it out.
http://www.oracle.com/technology/sample_code/tech/java/jms/unidomain/AsyncClient.java.html
Does JMS directly support XML?
Location: http://www.jguru.com/faq/view.jsp?EID=1215
Created: Nov 22, 1999
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
You can pass XML data in the body of a text message, and, of course, you can do
just about anything with an object message. Optionally, some vendors plan to
support other message types. Given the rapid growth and widespread use of XML,
it's likely that several vendors will offer direct XML support.
At this time, the following vendors/products provide some form of direct support for
XML:
Another one.
Author: Tom Barnes (http://www.jguru.com/guru/viewbio.jsp?EID=569489), Dec 2,
2001
WebLogic 6.0+ JMS also has some XML support.
Which JMS vendors fully support JNDI look-up operations for connection
factories and destinations?
Location: http://www.jguru.com/faq/view.jsp?EID=1304
Created: Nov 28, 1999
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
At this time, the following vendors/products provide some form of direct support for
JNDI look-up operations via their JMS server:
JMS clients must set up the proper network-capable objects, for example, connection
factories, in order to obtain access to other server-resident objects, for example,
connections and topics. The latter objects are, of course, fundamental to JMS-based
interclient communication.
With some JMS implementations, a client obtains a connection factory directly using
local instantiation (new AVendorConnectionFactory()). This approach requires
access to server-oriented classes. In some environments, it's preferable not to
distribute the vendor's classes (typically, housed in JAR files) to network hosts
executing JMS clients.
...
topicCon.createTopicSession(false, CLIENT_ACKNOWLEDGE);
...
...
topicCon.createTopicSession(false, AUTO_ACKNOWLEDGE);
...
With client acknowledgment, a client can allow messages to accumulate until some
arbitrary application condition:
...
topicCon.createTopicSession(false, CLIENT_ACKNOWLEDGE);
...
When a client acknowledges a message, the acknowledged message and all "older"
messages become unavailable for future processing.
Sort of. In this situation, in general, you can improve throughput by setting the
acknowledgment mode to permit duplicates, that is, by allowing the JMS server to
avoid the overhead of the once-and-only-once guarantee:
...
topicCon.createTopicSession(false, DUPS_OK_ACKNOWLEDGE);
...
Comments and alternative answers
Also.
Author: Tom Barnes (http://www.jguru.com/guru/viewbio.jsp?EID=569489), Dec 2,
2001
BEA WebLogic JMS 6.0+ provides two approaches here: a non-reliable multicast
pub/sub mode where there is no acknowledge involved, and a proprietary
acknowledge mode "NO_ACKNOWLEDGE".
If your goal is to improve performance, you can also get a near equivalent
performance boost by defering client acknowledges until the consumer has processed
a number of messages (ack every 50 for instance).
No and yes. JMS provides no analog to structured, remote method invocation, that
is, with strong data typing of arguments packaged succinctly in a single method call,
and with a type-checked return value.
On the other hand, for quick-and-dirty synchronous communication from a client that
normally plays the role of a consumer with respect to some topic, the consumer
client can use QueueRequestor or TopicRequestor to send a message via a
temporary queue/topic and wait for a reply. Communication is message-oriented;
thus, it is somewhat unstructured, or at least, differently structured, compared to a
method invocation.
Should the producing client store data in a message's header or its body?
Location: http://www.jguru.com/faq/view.jsp?EID=1592
Created: Dec 1, 1999
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
Decisions regarding where to store data should be based on the following guidelines:
If consuming clients will be using the data to filter the messages they receive from
the JMS server, this data should be small and stored as a message property. In this
case, any inefficiencies related to "top-heavy" headers, data conversions to and from
strings, and so on will more than likely be offset by the savings in not having to
delivery a significant percentage of the messages to a consuming client(s),
depending on the message selecting criteria.
If messages potentially transport a large amount of data, and consuming clients are
interested in only certain data-laden messages, it makes sense to put the data in the
message and a coordinating, or identifying, property name and value in the header,
in order to maximize the message selection/filtering capabilities that are available
with JMS.
How does a client application create a transaction object?
Location: http://www.jguru.com/faq/view.jsp?EID=2566
Created: Dec 14, 1999 Modified: 2000-08-03 22:25:31.928
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
How you gain access to UserTransaction objects varies depending on the type of
client. Enterprise JavaBeans provides two types of transaction management:
In other environments, for example, a web server that supports servlets and/or
JavaServer Pages (JSP), a JMS server, and others, you obtain a UserTransaction
object via JNDI. Of course, for a servlet to obtain a UserTransaction object, there
must be a JTS-capable server to deliver the object.
Typically, the server provides the JNDI look-up name either directly or via a system
or server property. For example, with the WebLogic server, you would use a code
segment similar to the following:
...
Context c = new InitialContext();
UserTransaction ut = (UserTransaction)
c.lookup("javax.jts.UserTransaction");
ut.begin();
// perform multiple operations...
ut.commit()
...
With J2EE implementations, you obtain the UserTransaction object with a code
segment similar to the following:
...
Context c = new InitialContext();
UserTransaction ut = (UserTransaction)
c.lookup("java:comp/UserTransaction");
ut.begin();
// perform multiple operations...
ut.commit()
...
If the environment provides the UserTransaction object via a system property, you
would use a code segment similar to the following:
...
String transName = System.getProperty("jta.UserTransaction");
Context c = new InitialContext();
UserTransaction ut = (UserTransaction) c.lookup(transName);
ut.begin();
// perform multiple operations...
ut.commit()
...
JNDI remote look-up names and property names vary, of course, across
servers/environment.
WebSphere 5.0
Author: Christoph Ernst (http://www.jguru.com/guru/viewbio.jsp?EID=1106402),
Aug 6, 2003
In WebSphere 5.0 the JNDI-Lookup works like
UserTransaction ut = (UserTransaction)
ctx.lookup("jta/usertransaction");
See e.g. http://www-
3.ibm.com/software/webservers/appserv/doc/v30/ae/web/doc/ent_beans/atswpgec.htm
The link above is a bit outdated (from WAS 3.0 documentation). Check the current Infocenter for detai
support in WAS 5.0:
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.websphere.base.doc/info/a
The lookup "jta/usertransaction" is still supported for J2EE apps with a spec level of 1.2 or lower. But
1.3 or later "java:comp/UserTransaction" is demanded.
Re[2]: WebSphere 5.0
Author: William Koscho
(http://www.jguru.com/guru/viewbio.jsp?EID=1148721), Feb 24, 2004
I am familiar with looking up the JNDI reference, but I am having trouble
defining the UserTransaction in Websphere. Can someone help me to set it up?
How do I create a javax.transaction.UserTransaction object and map it to
"java:comp/UserTransaction"? I am using WSAD 5.1 - any help is appreciated.
Thanks, Bill
From J2EE 1.3 specs: "The J2EE platform must provide an object
implementing the javax.transaction.UserTransaction interface to all web
components. The platform must publish the UserTransaction object in the
Java™ Naming and Directory Interface (JNDI) name space available to
web components under the name java:comp/UserTransaction."
using java:comp/UserTransaction
Author: Radhakrishnan Nariangadu
(http://www.jguru.com/guru/viewbio.jsp?EID=752623), Aug 4, 2005
Can I use the J2EE JNDI lookup even within a EJB container?
I'm developing a Hibernate based DB component that will provide a uniform
transactional interface anywhere,ie, J2EE container or normal JVM. Therefore within
a Bean managed Session bean, rather than obtaining UserTransaction from the
EJBContext will everything work smoothly if I obtain the UserTransaction using the
JNDI lookup?
...thanks in advance
What are the ramifications of mixing JTA and non-JTA transactions where
the same resources are involved?
Location: http://www.jguru.com/faq/view.jsp?EID=2570
Created: Dec 14, 1999
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9)
If mixed transactions are necessary (for whatever reason), the application should
manipulate the transactions in serial order, that is, start and finish the JTA
transaction before creating the non-JTA transaction (or vice versa). If, for example, a
JMS client creates a transaction via a UserTransaction and this transaction uses a
database resource via the transaction manager, there could be problems if the same
application directly accesses the database using a shared database connection.
There are many subtle and complex interactions between the use of
transactional
resources and threads. To ensure correct operation, web components
should obey
the following guidelines, and the web container must support at least
these usages.
It depends on the server implementation. The JTA and JTS specifications define
client-, application-, and transaction manager-level operations. There is nothing to
prevent a Java application server from implementing, JMS, EJB, and JTS functionality.
On the other hand, it could (if available) obtain transaction manager services
indirectly from another server.
Under certain conditions, yes. In this particular case, the JMS server would have to
implement the appropriate resource-related interfaces in javax.transaction.xa so
that the JTS transaction manager can enlist the JMS server as an intermediary,
playing the role of a resource manager with respect to the JMS application.
The JMS specification does not require that JMS implementations support distributed
transactions. If a JMS implementation supports distributed transactions, it's likely
that it will do so through the JTA API, providing a JTA UserTransaction object via
JNDI.
Sun manages the JMS-INTEREST list. You can signup and read the archives at
http://archives.java.sun.com/archives/jms-interest.html.
The JMS API describes the ConnectionFactory and TopicConnectionFactory.
These are also described as "administered'. In order to build an application
using JMS, what do I start first and how? Specifically, what parameters are
required to get a connectionFactory running?
Location: http://www.jguru.com/faq/view.jsp?EID=20779
Created: Mar 6, 2000 Modified: 2000-03-06 08:56:49.488
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9) Question
originally posed by m gottshall (http://www.jguru.com/guru/viewbio.jsp?EID=8652
An application receives certain JMS-related objects from a JMS factory that are
administered in the sense that these resources are controlled by the JMS server's
security subsystem. The security subsystem varies from vendor to vendor and is not
part of the JMS specification from Sun Microsystems. Most JMS middleware vendors
provide a graphical console for administering these resources.
try {
qcf = new progress.message.jclient.QueueConnectionFactory(url, "");
con = qcf.createQueueConnection(userId, password);
session = con.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
}
catch (Exception e) { /* handle exception */ }
In order to set up a JMS-capable application, that is, in order to access JMS services
within a distributed application, you must:
This process involves several steps, but the resulting messaging capabilities are
extensive. Also, this process is "routine" and amazing similar for each application, so
it's pretty easy to write a convenience class that performs these step, and that is
configurable for different topics and/or queues.
Of the steps listed previously for enabling JMS services in an application, the first
step varies somewhat across vendors. Some vendors provide connection factories via
object instantiation, as in the previous example. In this case, you must know the
class name for the connection factory. Other vendors deliver the connection factory
via a JNDI look-up operation, in which case you must know the appropriate look-up
symbol, for example, "topicConnectionFactory". These minor details are explained
in the vendor's documentation.
The JMS FAQ includes several complete example programs that demonstrate how to
set up JMS services in an application, as well as how to employ those services. In
addition, most vendors provide demonstration programs as part of their software
distribution.
Vendors who provide JMS implementations must implement the core functionality;
implementing optional functionality is, of course, optional. Another issue is vendor-
specific functionality beyond the optional functionality described by the specification.
Developers who use JMS implementations expect optional functionality to be missing
in some implementations. In contrast, vendor-specific functionality is not likely to
appear, in any other implementation (at least not as compatible, extended
functionality). Sometimes, vendor-specific functionality provides a truly needed
service for the vendor's customers; sometimes, it simply inhibits portable software
development.
A developer should expect each JMS implementation to be highly source-code
compatible with respect to the core functionality. That is, with minor changes to
various configuration-related code areas, an enterprise should be able to switch JMS
implementations half way through the development process, assuming that they
strive to write portable code. Of course, the user cannot expect runtime compatibility
among JMS implementations, because the specification does not address low-level
transport details, as well as other implementation issues.
The JMS specification, for example, does not address the overall JMS server
administration process. (The specification does outline so-called administered
objects.) Thus, each vendor's configuration and administration interface will vary, for
example, lightweight text-oriented, command-line tools versus graphical
administration consoles with elaborate resource monitoring charts. Even with these
variances, however, the developer should still be able to deliver applications with JMS
functionality that is approximately 95 percent portable.
Choosing a JMS vendor is not unlike choosing a relational database vendor, because
all parties in the enterprise must weigh the importance of the vendors' extensions, as
well as the robustness and portability of the core functionality. Although the JMS
specification has been around for a relatively short period (in terms of specification
and standards metrics), there are already several very stable JMS implementations,
with several more under development. (Compare this stability to, for example,
Swing.)
One issue that organizations should consider is whether or not a JMS implementation
is truly enterprise-capable and is compatible (as much as possible) with other
frameworks, for example, Enterprise JavaBeans (EJB). Furthermore, does the JMS
implementation make its administered objects available via standard services now
common in the Java arena, such as the Java Naming and Directory Interface (JNDI)?
See the JMS corner of the Java universe for a list of JMS vendors. See the Taco
framework for an example of JMS-related software that is striving to be 100 percent
portable.
Responding about MQSeries, the JMS implementation is provided by IBM under the
MA88 Support pack available at http://www-
4.ibm.com/software/ts/mqseries/txppacs/ma88.html and it's free!
Comments and alternative answers
The same as any client would use JMS. At this point there is no integration, but it is
planned for a future release of the EJB spec.
Comments and alternative answers
Is there any reason why a message can't be sent to an applet via JMS?
Location: http://www.jguru.com/faq/view.jsp?EID=32395
Created: Apr 5, 2000 Modified: 2000-04-05 06:27:25.621
Author: Benoit Xhenseval (http://www.jguru.com/guru/viewbio.jsp?EID=3363)
Question originally posed by Andrea O. K. Wright
(http://www.jguru.com/guru/viewbio.jsp?EID=30197
No. It all boils down to the standard applet limitations and your chosen
implementation of JMS.
To get around the firewall issue, nothing could stop you from implementing a simple
JMS client using HTTP stream (i.e. keep the connection open) to communicate with a
servlet that would register on your async backbone. Soon, some commercial JMS
implementation could implement it.
No. There's no particular reason why you can't do that, but you would have to work
around it a little bit.
Communication between EJBs and servlets is very much possible. In fact, one of the
advantages of JMS is that it can be used to link very different applications running on
different environments or separate JVMs. What you need to have is a message
producer and consumer each at both levels, i.e., at your EJB side as well as on your
servlets. So, for your servlet to communicate with EJB it would have to send a
request via a message producer (to a named destination like a queue or topic),
which would be read by the EJB's message consumer on the other end, and vice
versa.
Any time that multiple destinations are involved, for example, subscriptions to
multiple topics, the preferred approach (in my opinion) is to design a separate class
(either inner or conventional, depending on the circumstances) that functions as a
message listener for each topic, and then manage each topic in its own session. It's
possible, of course, to create multiple TopicSubscriber instances, one per topic,
each registered with a common message listener and associated with the same
session. In most situations, the latter approach does not scale well and can lead to
readability and maintenance problems.
Also, note that sessions are single-threaded contexts. That is, a session uses a single
thread of execution for all registered message listeners. Hence, managing multiple
topics and listeners within the same session (in effect) attenuates the asynchronous
message-handling operations. Suppose that multiple messages arrive at
approximately the same time (for example, one per topic for several topics). In this
case, all messages except one must wait while the session handles one message
notification (executes the registered listener). In this scenario concurrency can be
improved by designing listeners with dedicated execution threads. Of course, if there
are dependencies among the message-handling operations, for example, common
data, the application must accommodate these critical-region issues.
Has JMS replaced Java Message Queue? More importantly, which technology
should a developer be using?
Location: http://www.jguru.com/faq/view.jsp?EID=45671
Created: May 7, 2000 Modified: 2000-05-07 14:26:24.506
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9) Question
originally posed by CHARLES TAM
(http://www.jguru.com/guru/viewbio.jsp?EID=45298
JMQ does not replace JMS; JMQ is an implementation of the JMS specification. JMQ is
now sold as Sun Microsystems software. JMQ is only one of several JMS
implementations. Enterprises shouldn't "jump to JMQ" before considering alternative
JMS implementations.
I am quite new in JMS and would like to try it out. Can you please suggest
any complementary software?
Location: http://www.jguru.com/faq/view.jsp?EID=47109
Created: May 10, 2000 Modified: 2000-05-10 15:10:40.976
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9) Question
originally posed by CHARLES TAM
(http://www.jguru.com/guru/viewbio.jsp?EID=45298
free JMS
Author: JP Bonn (http://www.jguru.com/guru/viewbio.jsp?EID=937269), Jul 3, 2002
Look at JBoss also - http://www.jboss.org The JBossMQ is a free, open source JMS
impelmentation.
Yes, check out The JNDI Tutorial online and/or buy a copy of it here.
Check out The JNDI Tutorial. It's also available on the web.
For other books that are relevant to JNDI, check out Are ther any books that provide
decent JNDI coverage?.
If your EJB does not need to know about the results of the aynch calls, then you can
use JMS to send an asynch. message to another part of the system.
Another alternative is to place the multithreaded code inside a CORBA or RMI server
and call this from your EJB. Always keep site of the big picture, RMI and CORBA are
part of J2EE and can be used as part of a 'J2EE' solution.
There are some things that these technologies can do that EJB at this present time
cannot.
The current release of J2EE (1.2.1) support EJB 1.1 specification so it doesn't
implements JMS over EJB.
This kind of EJB appears only in the EJB 2.0 specifications (available at
http://java.sun.com/products/ejb/docs.html).
At this time only BEA and Silverstream support this specification. Probably in the
future more Vendors will follow this new specification, so wait...
A client cannot create a queue, except temporary queues. If your question refers to
the createQueue() method of a QueueSession, the JMS 1.0.2 specification states,
that this method is not to create the physical queue instance but only the destination
object, which is the address of the queue. Creating physical queues is an
administration task not to be performed by a client. This is well separated in JMS.
In a system where one client sends a message to one specific peer out of
thousands, is it appropriate to use a single queue and have the peers find
their messages using selectors?
Location: http://www.jguru.com/faq/view.jsp?EID=86702
Created: Jun 26, 2000 Modified: 2000-06-26 06:51:20.237
Author: Andreas Mueller (http://www.jguru.com/guru/viewbio.jsp?EID=23179)
Question originally posed by Henrik Hermansson
(http://www.jguru.com/guru/viewbio.jsp?EID=44407
This is one possibility, but very slow, I think. Every message has to pass every
receiver to check if the specific message selector does match. Also, not every vendor
supports multiple receivers on a single queue. I would suggest, use publish/subscribe
and map your selection criteria to topics or, if your vendor supports this, to topic
hierarchies. But your sender client has to perform some pre-selection to publish to
the right topic.
Comments and alternative answers
Does this mean that you suggest setting up a sub-topic for each client(out of
thousands) and only listen on that one sub-topic?
Or do you mean to setup a smaller number of topics and then use message selectors
on the client to further limit the message delivery?
JMS specifically does not define how messages delivered to a queue are load
balanced across multiple consumers. It does not define an optional mechanism for
doing this. The reason it does not is that this involves complicated APIs that are quite
hard to define in a vendor neutral form. The EJB 2.0 message-driven bean facility
addresses this need by making the J2EE server responsible for integrating JMS, and
if the container provides some form of clustering/load balancing, then the container
handles this complexity. JMS vendors may provide some form of load balancing, but
if they do, it is completely outside the JMS specification. (Original answer from Mark
Hapner, Sun Microsystems)
Comments and alternative answers
Clarification
Author: Tom Barnes (http://www.jguru.com/guru/viewbio.jsp?EID=569489), Dec 2,
2001
While the JMS spec does not spec out load balancing, it does spec out that the same
message must not be delivered twice unless using the DUPS_OK_ACKNOWLEGE
mode. You can get an even better guarantee from JMS vendors that support user
transactions. You are right in thinking that queues make for a nice load-balancing
solution, the caveat is that the JMS vendor makes some effort not to favor any
particular consumer.
Are there any open-source JMS implementations?
Location: http://www.jguru.com/faq/view.jsp?EID=116665
Created: Aug 1, 2000 Modified: 2000-08-06 12:01:00.093
Author: Robert Castaneda (http://www.jguru.com/guru/viewbio.jsp?EID=4362)
Question originally posed by y yc
(http://www.jguru.com/guru/viewbio.jsp?EID=95609
and
www.swiftmq.com
Author: Mark Smith (http://www.jguru.com/guru/viewbio.jsp?EID=491756), Sep 6,
2001
www.swiftmq.com - It's open source, fast, relialbe, and mature.
Re: www.swiftmq.com
Author: Jason Dillon (http://www.jguru.com/guru/viewbio.jsp?EID=23800), Mar
18, 2002
SwiftMQ is not an open source JMS impl. It also appears that since v3.0 it is not
even free anymore.
Re[2]: www.swiftmq.com
Author: Mark Smith (http://www.jguru.com/guru/viewbio.jsp?EID=491756),
Mar 19, 2002
Yes, you are correct. They have changed their licensing unfortunately. Here is
a link of some open-source JMS vendors:
http://www.ejbnow.com/jms_links_page.html
No, a new thread is not spawned to handle each new message being passed to the
queue. A session can handle only one message at a time, i.e, it is a single thread of
execution. While one message is being processed, all the other messages need to
wait. To have messages delivered concurrently, you need to have multiple sessions.
See Sections 4.4.16 and 4.4.17 of the JMS 1.0.2 specification.
Where can I find the API documentation for Java Messaging Service (JMS)?
Location: http://www.jguru.com/faq/view.jsp?EID=134143
Created: Aug 24, 2000 Modified: 2000-08-24 11:15:19.844
Author: John Mitchell (http://www.jguru.com/guru/viewbio.jsp?EID=4)
The JMS API documentation is available from Sun's J2EE API documentation page.
JMS does not define a security API. JMS implementations provide vendor-specific
security facilities, typically, through a text-oriented console or a graphical
browser/console.
For this reason, (distributed) JMS clients should use a topic and queue design within
their application components that facilitates the factoring of and provision of security
at several levels--whatever matches the needs of the application components. In this
way, an administrator can set the security characteristics of various topics and
queues to allow the proper level of accessibility by user and by application
functionality.
The JavaMail API is a mail user agent (MUA) for creating programs for a user to
get/send email messages, using standard mail protocols.
James (and others) is a mail server / mail transfer agent (MTA). It is responsible for
the actual sending and delivery of mail messages, as well as queueing messages
when something is down, holding them for the user to receive, etc.
The Java Message Service (JMS) is a Java API for interclient messaging. JMS provides
a general-purpose facility for sending messages among distributed application
components. It does not provide email functionality.
How can I integrate JMS third-party software with EJB application servers
(both J2SDKEE 1.2.1 and, for example, the WebLogic server)? And, how can
I run the client application? A sample program would be useful?
Location: http://www.jguru.com/faq/view.jsp?EID=201414
Created: Sep 8, 2000 Modified: 2000-09-11 07:40:17.597
Author: Ron Kurr (http://www.jguru.com/guru/viewbio.jsp?EID=132270) Question
originally posed by Chandra Shekar
(http://www.jguru.com/guru/viewbio.jsp?EID=126461
If you want everything to participate within the same transaction, you can't. For
example, if you are in an EJB that has a transaction context started and you place
something on a non-Weblogic JMS queue and the transaction ends up rolling back,
the message you placed on the JMS queue will still remain.
Comments and alternative answers
If you have a messaging system that can be accessed by both Java and C++, you
might consider storing your messages in the form of XML. XML is platform and
language independent and might get you where you want to go. I'm not doing C++
right now, so I can't point you to a JMS implementation that also has a C++
interface.
Comments and alternative answers
Talarian's middleware
Author: John Reid (http://www.jguru.com/guru/viewbio.jsp?EID=241194), Oct 4,
2001
Talarian offers high performance, scalable publish/subscribe and queueing
middleware that Java, JMS, C and C++ clients can use interoperably. See
http://www.talarian.com/
IBM MQSeries
Author: Michael Lanzetta (http://www.jguru.com/guru/viewbio.jsp?EID=1017593),
Oct 25, 2002
MQSeries from IBM also has C++ & Java bindings, as well as bindings for many
other languages. I haven't used any of the others, but I've used MQSeries for this
exact purpose and it worked well.
Pricing is really the issue. Does anyone know of any free solutions for this problem
(besides vanilla JNI)?
Suresh, I think we'll need a few more details before you can be helped. How is JMS
being used here? Are you using queues or pub-sub? What type of payload are in your
messages? Have you looked to verify that you don't have some sort of deadlock
situation causing your thread to wait forever? How is the communication between the
EJBs being done? Is it via JMS or a direct EJB call?
Comments and alternative answers
The payload is quite high in my system, and I don't know whether it is the culprit. The
EJBs are communicating through JMS (no look-up involved). In fact, these
components don't even know with whom they are communicating. The application
component just publishes the message through a topic and waits for the response.
There are service components registered to listen these topics, which on receiving
these messages, sends out a response, which the application receives using a
receive() method.
I am rather new to the JMS technology and know only the basics as of now. I was
wondering whether it is a problem to incorporate Applets to receive messages
from the application server using the pub/sub model, and to display the message
or not?
I have an applet in my JSP page and I want to display the message that it receives
from an EJB. How & where is the JNDI naming lookup handled?
I would be grateful if you could help me out and also tell me how the above may
be achieved (basic architecture).
Regards, Sanjit
Sun has some example programs that you might want to look at.
[. e.g. the client displays alarm status of devices. If I use EJB to periodically check
the database for alarm status change, how to program the EJB to forward notification
to clients when the status is changed? ]
Asynchronous notification is a known hole in the first versions of the EJB spec. The
recommended solution to this is to use JMS, which is becoming available in J2EE-
compliant servers.
The other option, of course, is to use client-side threads and polling. This is not an
ideal solution, but it's workable for many scenarios.
See also OK, so EJB doesn't support user-created threads. So how do I perform tasks
asynchronously? .
The general answer is that it would be best to use a bit of both. There will always be
an overhead on the broker for the creation of a Topic, but if variations are small,
(for example, less than 200), throughput should be significantly better. This is
because of the overhead incurred in applying the selector to each message, as
opposed to routing a message to a particular client.
Comments and alternative answers
What is the best way to implement the subscribe side in the pub/sub
connection?
If option 2 is the best way, I have a question: What is the best way to close
the connection? Is there a method that tells me when to close the line?
Location: http://www.jguru.com/faq/view.jsp?EID=223045
Created: Oct 5, 2000 Modified: 2000-10-06 06:54:13.74
Author: Robert Davies (http://www.jguru.com/guru/viewbio.jsp?EID=139017)
Question originally posed by Nir Alon
(http://www.jguru.com/guru/viewbio.jsp?EID=109329
If you want to guarantee that all messages are received by a subscriber, then use a
durable subscriber. If you explicitly close the connection, or there is a network
failure, all unacknowledged messages will be re-delivered the next time you
subscribe.
Using JMS we want to transfer files from server A to server B. Is there any
limit to the size to a file that can be transfered using JMS? Is it possible, for
example, to transfer 50- or 60-MB files.
Location: http://www.jguru.com/faq/view.jsp?EID=226206
Created: Oct 10, 2000 Modified: 2000-10-16 06:25:54.946
Author: Rajiv Kanaujia (http://www.jguru.com/guru/viewbio.jsp?EID=226198)
Question originally posed by Ramesh Parthasarthy
(http://www.jguru.com/guru/viewbio.jsp?EID=94849
Theoretically, there are no limits to the size of JMS message. Message size limitations
can be imposed by a JMS service provider.
Comments and alternative answers
You may find some through JMS vendors or Business Analyst groups. Try visiting
some of the JMS provider sites.
Are there any JMS implementations that utilize email under the covers for
interclient communication?
Location: http://www.jguru.com/faq/view.jsp?EID=238331
Created: Oct 27, 2000 Modified: 2000-10-28 07:29:25.967
Author: Mario Prados (http://www.jguru.com/guru/viewbio.jsp?EID=238319)
Question originally posed by John Zukowski PREMIUM
(http://www.jguru.com/guru/viewbio.jsp?EID=7
I'm not 100% sure, but I could say that probably nobody will be implementing JMS
using e-mail as the underlying transport. If you take a look at Sun's JMS web page,
you'll see the list of JMS implementors. All of them are MOMs (IBM, Fiorano, TIBCO,
Allaire, etc.); thus, you can expect all of them will put JMS interfaces on top of their
respective products.
Comments and alternative answers
Yes, all the major vendors are not using email as their...
Author: Mark Pollack (http://www.jguru.com/guru/viewbio.jsp?EID=231174), Oct
30, 2000
Yes, all the major vendors are not using email as their underlying transport. However,
e-mail and JMS/MOM will come together to some extent when message driven beans
(EJB 2.0 spec) become more popular.
What's MOM?
Location: http://www.jguru.com/faq/view.jsp?EID=240828
Created: Oct 30, 2000 Modified: 2000-10-30 20:09:44.097
Author: neal ravindran (http://www.jguru.com/guru/viewbio.jsp?EID=17737)
Question originally posed by John Zukowski PREMIUM
(http://www.jguru.com/guru/viewbio.jsp?EID=7
Middleware is usually something that sits between a client and a server. Or, in
simpler terms, between a requestor and a requestee. A request can be considered as
a message. Different software components in a distributed computing network need
to pass messages between themselves, asynchronously. MOM, or Message Oriented
Middleware is software that sits between two such communicating software
components. MOM products facilitate this message-passing by using a technique
called queueing. Messages are stored in queues until the client which requested it
can "read" it in a FIFO fashion, or on a priority basis. The queueing technique thus
eliminates complex connection overhead, and also helps the communicating software
components work independent of time (or asynchronously). IBM's MQSeries and MS
MSMQ are examples of MOMs.
What is the relationship between types of the sent JMS messages and types
of the received JMS messages? Can they be different types?
Location: http://www.jguru.com/faq/view.jsp?EID=270806
Created: Dec 6, 2000 Modified: 2000-12-06 12:38:32.329
Author: Rajiv Kanaujia (http://www.jguru.com/guru/viewbio.jsp?EID=226198)
Question originally posed by Luis Rivera
(http://www.jguru.com/guru/viewbio.jsp?EID=247475
Theoretically, if you have a single JMS provider, there should be no difference in the
message type (for both send and receive). If you have multiple JMS providers, and
they are talking to each other through a bridge, then there is a possibility that the
message types may differ. The bridge vendor should document these issues.
What encryption options are there for sending messages through JMS?
Location: http://www.jguru.com/faq/view.jsp?EID=277009
Created: Dec 13, 2000 Modified: 2000-12-13 18:05:14.771
Author: Rajiv Kanaujia (http://www.jguru.com/guru/viewbio.jsp?EID=226198)
Question originally posed by John Zukowski PREMIUM
(http://www.jguru.com/guru/viewbio.jsp?EID=7
Encryption is not handled by the JMS specification. It is left to the JMS provider to
implement and provide encryption and decryption of messages. These days, Progress
Software’s SonicMQ is a leading JMS provider and they have a robust encryption
mechanism called Quality of Protection. They also provide an SSL-related feature,
which also has build in encryption. Check out their documentation to see what they
do…
So the answer to your question is no, if what you meant by "affecting" is not-yet
acknowledged.
I want to use JMS for transfering data between two applications that are
not on the same host. Where can I find JMS providers (that is, JMS
implementations) for HTTP exchange, for file exchange, for socket
exchange?
Location: http://www.jguru.com/faq/view.jsp?EID=289123
Created: Dec 29, 2000 Modified: 2001-01-02 12:04:23.441
Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7) Question
originally posed by jeanbaptiste_g jeanbaptiste_g
(http://www.jguru.com/guru/viewbio.jsp?EID=284400
Check out SonicMQ. It supports different protocols like TCP/IP, HTTP, and SMTP, can
send XML messages, and supports multi-domain routing.
I want to use JMS for transfering data between two applications that are
not on the same host. Where can I find JMS providers (that is, JMS
implementations) for HTTP exchange, for file exchange, for socket
exchange?
Location: http://www.jguru.com/faq/view.jsp?EID=289805
Created: Dec 30, 2000 Modified: 2001-01-02 12:06:39.24
Author: Rajiv Kanaujia (http://www.jguru.com/guru/viewbio.jsp?EID=226198)
Question originally posed by jeanbaptiste_g jeanbaptiste_g
(http://www.jguru.com/guru/viewbio.jsp?EID=284400
The Session is a way of interacting with the JMS router, and providing transactional
support. It does not affect the delivery of messages on topics. You can use a session
to post a message to a topic, and still retrieve that message from a MessageListener
that is also registered with a session on the same topic regardless of JVM or location.
That is one of the benifits of JMS, it allwows distributed message processing, with a
variety of delivery options.
Is it possible to browse a topic? Or, is browsing only available on queues?
Location: http://www.jguru.com/faq/view.jsp?EID=307786
Created: Jan 20, 2001 Modified: 2001-01-22 15:27:57.034
Author: Chris Dupuy (http://www.jguru.com/guru/viewbio.jsp?EID=40966) Question
originally posed by Dean Sheppard
(http://www.jguru.com/guru/viewbio.jsp?EID=14227
The JMS specification does not define a way of browsing a topic, but it is really quite
simple: just subscribe to the topic using a non-transaction, non-durable subscriber.
You get the messages that are posted to the topic, but you do not affect delivery to
other subscribers. In a Queue there is a defined way of browsing, because looking at
or retriving messages from a queue could affect delivery to other clients.
You can make two JMS client applications, say AppA and AppB. Make AppA listen to
topic ‘forA’. Make AppB listen to topic ‘forB’.
If AppA sends a message to topic ‘forB’, AppB will receive it. If AppB sends a
message to topic ‘forA’, AppA will receive it.
For sample code etc, try downloading SonicMQ (as a JMS server) and go through the
samples.
In a simple application that I tried, I removed the ‘custom’ header scenario and just
forwarded the contents of the message (text message), which worked without any
problems.
Try using SonicMQ bridges, which already has something like that.
Reconsider what you are trying to achieve. Other design alternatives include
message selectors or a dead message queue.
If you don't want to acknowledge earlier messages because they are not relevant to
you, don't consume them; use a message selector to get only the messages you care
about. If you're using queues, it is important to have another receiver to consume
these messages, or eventually the queue will back up.
If you don't want to acknowledge a message because processing failed, but you don't
want to stop processing subsequent messages, requeue the bad message in a "dead
letter" queue for manual intervention, acknowledge it, and move on to the next.
Is there a standard JMS way that works with all JMS providers to notify a
producer that there are new consumers subscribed? I found a way with my
SpiritWave provider to do that--I just wait for SubscribtionEvent, but I think
this will not work if I change to another JMS provider.
Location: http://www.jguru.com/faq/view.jsp?EID=347442
Created: Mar 8, 2001 Modified: 2001-04-18 18:20:53.042
Author: Doug Erickson (http://www.jguru.com/guru/viewbio.jsp?EID=1718)
Question originally posed by Christoph Sawicki
(http://www.jguru.com/guru/viewbio.jsp?EID=339101
In practice, however, sometimes it's nice to know at least if anyone is out there
listening, so that you can save the overhead of message production. To be portable, I
think you'd have to implement your own mechanism to do this at the application
level.
I would like to know what is the format of a JMS message. If I should create
a JMS message without using javax.jms classes, how should I create this
message?
I'm using JMQ 2.0 to receive a JMS message, but suppose whoever sends
me a message can't use Java. So how should he write the message?
Location: http://www.jguru.com/faq/view.jsp?EID=347444
Created: Mar 8, 2001 Modified: 2001-03-09 19:36:17.594
Author: Doug Erickson (http://www.jguru.com/guru/viewbio.jsp?EID=1718)
Question originally posed by Aesse Italia Aesse Italia
(http://www.jguru.com/guru/viewbio.jsp?EID=346484
As a consequence, in order to use a vendor's message system, you have to use its
client software. In the case of JMQ, the client is available only in Java. There's no
way to connect to JMQ from another environment and send and receive messages.
JMS defines the interface that the vendor should present to your Java application.
The value here is that if you don't like, for example, JMQ, you can replace it with
another product that does support the functionality you need, without re-writing your
app.
JMS has no inherent support for email operations. Consider the JavaMail API.
Is JMS the right thing for simple asynchronous message passing? I want to
build a peer-to-peer network, where each node has only 2-5 connections.
They should be able to forward asynchronous messages. I assume that
installing a JMS provider on each single node would be too much for it,
because of the few connections. On the other hand, RMI is too simple,
especially because the asynchronism has to be implemented by threads.
Would it be a bad idea to install a JMS provider on each machine? Does
there exist a better way for message passing?
Location: http://www.jguru.com/faq/view.jsp?EID=406021
Created: Apr 19, 2001
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9) Question
originally posed by Benedikt Voigt
(http://www.jguru.com/guru/viewbio.jsp?EID=402582
Answer by Jerry Smith Re: Is JMS the right thing for simple asynchronous message
passing? Yes, JMS is a common solution. It is not necessary to have a participating
JMS server on each node. For this scenario, a single JMS server could provide the
message handling for all participating nodes. The JMS server could be located on one
of the nodes, or on a neutral network host/node.
Comments and alternative answers
Also consider using Jini event service, RIO events (above Jini) or JavaGroups
Author: anthony warden (http://www.jguru.com/guru/viewbio.jsp?EID=274895), Sep
11, 2002
See http://jini.org and http://www.javagroups.com/javagroupsnew/docs/index.html
The questions was about p2p - so having a central / single / non distributed JMS
server may not accord with the design philosophy stated.
How
Author: Arthur Chan (http://www.jguru.com/guru/viewbio.jsp?EID=1036721), Dec
11, 2002
Jerry, you said, "For this scenario, a single JMS server could provide the message
handling for all participating nodes. The JMS server could be located on one of the
nodes, or on a neutral network host/node."
May I ask how do you do this? Would you please be so kind to send me some sample
code of using JMS for p2p messaging? Many thnx.
Are there any JMS implementations that are optimized for mobile devices
such as Palm? (The only product I know is iBus//mobile from Softwired.)
Location: http://www.jguru.com/faq/view.jsp?EID=406071
Created: Apr 19, 2001 Modified: 2001-04-19 17:21:13.372
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9) Question
originally posed by Sandro Dindo
(http://www.jguru.com/guru/viewbio.jsp?EID=387974
regards,
Rob Glance
Customer Support Engineer
Ashnasoft Corp
How do you pass a file from a message producer to a consumer using JMS?
Location: http://www.jguru.com/faq/view.jsp?EID=407792
Created: Apr 22, 2001
Author: Jerry Smith (http://www.jguru.com/guru/viewbio.jsp?EID=9) Question
originally posed by krishna kumar
(http://www.jguru.com/guru/viewbio.jsp?EID=388042
Upon consumption, just call the msg.getObject() method to return your File object.
Answer by Alessandro A. Garbagnati
Josh,
I'm not sure that passing the File object will work. The problem is that the File object
is just an "abstract representation of file and directory pathnames" (as stated by the
JDK documentation), and it does not contain the file itself. What if the file is not
located on the same system?
Your solution it's ok, just do not use java.io.File;
Answer by kunal khanna
I just used fileInput stream to read a file into a byte array,transmitted the array to a
queue. The consumer reads this byte array and writes it to another file. It runs very
well...
Comments and alternative answers
Where can I learn (more) about CORBA (Common Object Request Broker
Architecture)?
Location: http://www.jguru.com/faq/view.jsp?EID=431188
Created: May 30, 2001
Author: John Mitchell (http://www.jguru.com/guru/viewbio.jsp?EID=4)
Where can I learn (more) about using JNDI (Java Naming and Directory
Interface)?
Location: http://www.jguru.com/faq/view.jsp?EID=431212
Created: May 30, 2001
Author: John Mitchell (http://www.jguru.com/guru/viewbio.jsp?EID=4)
Where can I learn (more) about Java's support for developing multi-
threaded programs?
Location: http://www.jguru.com/faq/view.jsp?EID=431248
Created: May 30, 2001
Author: John Mitchell (http://www.jguru.com/guru/viewbio.jsp?EID=4)
Where can I learn (more) about Java's support for transaction processing?
Location: http://www.jguru.com/faq/view.jsp?EID=431948
Created: May 31, 2001
Author: John Mitchell (http://www.jguru.com/guru/viewbio.jsp?EID=4)
However, there's nothing stopping you from using another JMS provider (like
OpenJMS from within Tomcat.
-chris
Comments and alternative answers
JBossMQ
Author: Colin Bennett (http://www.jguru.com/guru/viewbio.jsp?EID=500093), Sep
19, 2001
I have used the open-source JBoss JMS server (JBossMQ) with Tomcat and it works
wonderfully. Easy to set up, sticks with the specs, powerful, fast, and open source.
Re: JBossMQ
Author: Frank Shen (http://www.jguru.com/guru/viewbio.jsp?EID=504656), Sep
26, 2001
I need to send a batch job request from the client to the server. This batch job will
run for hours. I don't want the client browser to be hanged. Is it a good situation to
use JMS. If so, can I cut off the network connection after the request has been
submitted? How do I do that?
Re[2]: JBossMQ
Author: Steve Lawton
(http://www.jguru.com/guru/viewbio.jsp?EID=1060438), May 13, 2004
JMS... err Batch job.. The information on the clients machine, should be
captured as a file. (presume you have said waiting file) The send on your
admin side for the client should have an action to send this file. Your servlet
should accept the single request of a file, and download it as one to the server,
(it wont stop the server). Or use JMS to send the file as one. If they have to be
recieved one at a time, then you have to wait.
Re[2]: JBossMQ
Author: Guido Medina (http://www.jguru.com/guru/viewbio.jsp?EID=1212409),
Nov 22, 2004
You dont need to use JMS to do that, less keep it simple, I already did that for a
different process (Oracle Batch Processes for the Dominican Republic Social
Security System), put a process manager in the context and using any data
structure (HashMap, Map, List, etc) control your Threads, you can have multi-
threading in the context and it works just perfect, my app also has an monitor for
the running process which you can kill (for DB was a statement.cancel() to do a
rollback) and with the data structure you avoid process duplication in case you
need it. Kind regards, Guido.
Re[3]: JBossMQ
Author: v konda (http://www.jguru.com/guru/viewbio.jsp?EID=1213241),
Nov 26, 2004
I need this functionality too. I was using OpenJMS but would like to avoid
if possible. What is a Process manager and how do you configure it in
Tomcat? Thanks.
Is it possible to integrate TIBCO system with EJB or, generally, with J2EE?
Is this done through the JMS-TIBCO connector? Is it possible to deploy EJB
directly on TIBCO?
Location: http://www.jguru.com/faq/view.jsp?EID=997068
Created: Sep 10, 2002 Modified: 2002-09-11 04:34:57.777
Author: Jon Dart (http://www.jguru.com/guru/viewbio.jsp?EID=996845) Question
originally posed by Francesco Marchioni
(http://www.jguru.com/guru/viewbio.jsp?EID=59707
TIBCO has a product called TIBCO Adapter for EJB that facilitates communication
between EJBs and services that use TIBCO's Rendezvous messaging system.
TIBCO also has a full-featured JMS implementation that can gateway JMS messsages
into and out of TIBCO Rendezvous.
You cannot deploy EJB directly on TIBCO, since TIBCO isn't a deployment platform
for EJBs.
anthony warden has also added the link to the TIBCO Enterprise for JMS, that
provides a standardized interface for enabling communications between J2EE-
compliant applications, Enterprise Java Beans, and application servers.
The integration with JBoss and weblogic is documented in the help files.