The dosend method, shown in the following example, sets up a queue to send messages. After creating the queue sender, this example sends out several messages. Providing the retrieved JMS Destination , create a receiver for a queue or a topic subscriber. Example demonstrates these steps for receiving a JMS message.
The dorcv method, shown in the following example, sets up a queue to receive messages off of it. After creating the queue receiver, it loops to receive all messages off the queue and compares it to the number of expected messages.
JMSUtils , for debugging and information access. Then execute JMSUtils , as follows:. You define a user within the administrator role in the security User Manager. Table describes these options. The commands describe the action to be taken and are discussed in Table To display the syntax usage, issue the JMSUtils command with no argument.
To display extensive information about the available command set, the argument options, and the behavior of each command, issue the following:. The following sections provide more detail on file-based persistence:. If a persistence file does not exist, OC4J automatically creates the file and initializes it with the appropriate data. Even if persistence is enabled, only certain messages are persisted to a file. For a message to be persisted, all of the following must be true:.
The Destination object is defined to be persistent within the persistence-file attribute in the jms. The message has a persistent delivery mode, which is the default. Messages sent to persistent destinations that are defined with a non-persistent delivery mode defined as DeliveryMode.
The complete semantics of which messages are persisted are documented within the JMS specification. To enable file-based persistence for Destination objects, specify the persistent-file attribute in the jms. The following XML configuration demonstrates how the persistence-file attribute defines the name of the file as pers. The path for the persistence-file attribute is either an absolute path of the file or a path relative to the persistence directory defined in application.
The JMS server will not create any directories for persistence files. So when a persistence file is defined in jms. Oracle Application Server may have multiple OC4J instances writing to the same file directory, even with the same persistence filename. Setting this attribute enables file-based persistence, but also creates the possibility that your persistence files can be overwritten by another OC4J instance. Each OC4J JMS Destination , which can be either a queue or topic, can be associated with a relative or absolute path name that points to a file that stores the messages sent to the Destination object.
Multiple persistence files can be placed in the same directory; persistence files can be placed on a remote network file system or can be part of a local file system. Media corruption—the disk system holding the persistence file fails abnormally or gets corrupted. External corruption—the persistence file is deleted, edited, modified, or otherwise corrupted by software. A java. It is an unrecoverable error to perform any of these actions on any of these files when they are being used by OC4J JMS.
However, when no OC4J JMS server is using a persistence file, you can perform the following administrative and maintenance operations on these files:. If an existing persistence file gets corrupted, an earlier version can be used as long as the association between the OC4J JMS Destination name and the file is maintained , pointed to by any suitable path name, to go back to the previous contents of the JMS Destination.
Persistence files cannot be concatenated, split up, rearranged, or merged. Attempting any of these operations causes unrecoverable corruption of the data in these files. You must never delete, move, copy, or otherwise modify this file, even for archival purposes. Attempting to manipulate the jms. The location of the persistence directory is defined in the application.
The sequence of operations when a JMS client enqueues or dequeues a message, or commits or rolls back a transaction, is as follows:. If a failure occurs during the pre-persistence or persistence phase, then the client receives a JMSException or some other type of error, but no changes are made to the persistence file. If a failure occurs in the post-persistence phase, the client may receive a JMSException or some other type of error; however, the persistence file is still updated, and OC4J JMS recovers as if the operation succeeded.
Lock files prevent multiple OC4J processes from writing into the same persistence file. If multiple OC4J JVMs are configured to point to the same file in the same persistence-file location, then they could overwrite each others data and cause corruption or loss of persisted JMS messages.
See "Enabling Persistence" for more information on persistence files. OC4J must have appropriate permissions to create and delete the lock file. If OC4J is terminated normally, then the lock files are cleaned up automatically. However, if OC4J is terminated abnormally, the lock files continue to exist in the file system. Because OC4J cannot distinguish leftover lock files from sharing violations, the user must manually remove all lock files before restarting OC4J after abnormal termination.
The remainder of the discussion in this subsection assumes that all lock files in question have been removed.
In other words, if OC4J terminates abnormally, the user modifies the JMS server configuration and restarts OC4J, the JMS server still attempts to recover all the persistence files in the original configuration, and, after recovery is successful, moves to using the new configuration specified. The server must be shut down or restarted repeatedly to give recovery another chance, until recovery is successful.
If you wish to bypass all recovery of the current configuration, you can remove the jms. We do not recommend doing this. If, for some reason, the jms. If messaging activity was in progress during abnormal termination, then OC4J JMS tries to recover its persistence files. Any data corruption of the types mentioned earlier is handled by clearing out the corrupted data; this may lead to a loss of messages and transactions.
If the headers of a persistence file are corrupted, OC4J JMS may not be able to recover the file, because such a corrupted file is often indistinguishable from user configuration errors.
The oc4j. If OC4J terminates normally, then the lock files are cleaned up automatically. However, if OC4J terminates abnormally for example, a kill -9 command , the lock files remain in the file system.
Because OC4J cannot distinguish leftover lock files from sharing violations, you must manually remove all lock files before restarting OC4J after abnormal termination.
The persistence directory is defined in the application. Other locations can be set within the persistence-file attribute of the Destination object. This is a single, persistent, global exception queue to store undeliverable messages in all of its Destination objects. The name, JNDI location, and persistence path name of the exception queue must be considered reserved words in their respective name spaces; any attempt to define other entities with these names is an error.
Messages can become undeliverable because of message expiration and listener errors. The following subsection explains what happens to undeliverable messages in the first case.
The message is wrapped in an ObjectMessage with appropriate property name and value copies performed as described elsewhere in this chapter , and the wrapping message is sent to the exception queue.
To affect the behavior of what goes into the exception queue, use the oc4j. The wrapping ObjectMessage has the same DeliveryMode as the original message. By default, messages expiring on nonpersistent or temporary Destination objects are not moved to the exception queue.
The messages sent to these Destination objects are not worth persisting and neither should their expired versions be. You can specify that all expired messages be sent to the OC4J JMS exception queue, regardless of whether they are sent to persistent, nonpersistent, or temporary Destination objects, by setting the oc4j. In this case, all expired messages are moved to the exception queue. Only message bodies are paged. Message headers and properties are never considered for paging.
This value is an estimate of the fraction of memory in use by the Java virtual machine JVM. This value can range from 0. The value ranges from somewhere above 0. For example, if the paging threshold is 0. After the message has been delivered to the client, it may once again be considered for paging out, depending on the memory usage in the server JVM.
If the memory usage fraction drops below the paging threshold, then the OracleAS JMS server stops paging out message bodies. The bodies of messages already paged out are not automatically paged back in. The paging in of message bodies happens only on demand that is, when a message is dequeued or browsed by a client. No value of the paging threshold is ever incorrect. JMS semantics are always preserved regardless of whether paging in enabled or disabled.
Control of the paging threshold does allow the OracleAS JMS server to handle more messages in memory than it might have been able to without paging. The following is the element order structure within the XML file:. The default setting is This setting applies only to the standalone configuration of OC4J.
This attribute is optional. The value should follow the JNDI rules for valid names. The location should be unique across all Destination objects and connection factory elements in jms.
There is no default. See "Recovery" for more details on the meaning of the persistence-file attribute. If multiple queue elements with the same name and different locations are declared in jms. If at least one of these multiple declarations specifies a persistence-file , that value is used for this queue.
The location should be unique across all topics and connection factory elements in jms. If multiple queue or topic elements with the same name and different locations are declared in jms. If at least one of these multiple declarations specifies a persistence-file , that value is used for this topic.
Table describes the attributes for any connection factory definition. If you want to add a topic connection factory, you must use a unique name. Thus, the following would be invalid. The following code sample shows queue and topic configuration fragments. This segment creates a queue foo and a topic bar. Certain locations are reserved and cannot be redefined within the jms.
When defining a persistence file for queues and topics, you can define the location and the filename. In addition, you can specify multiple persistence files, as long as the persistence filename is the same.
Thus, the persistence file is written out to two locations for the same queue. Alternatively, you cannot have two objects writing out to the same persistence file. Each queue or topic must have its own persistence filename, even if the locations are different.
None of these properties affect basic JMS functionality. If this is the resource provider for all applications global , then configure the global application. If this is the resource provider for a single application local , then configure the orion-application. To add a custom resource provider, add the following code to the chosen XML file as listed above :. This name is used in finding the resource provider in the application JNDI as:.
The name attribute identifies the name of the parameter, and its value is provided in the value attribute. Install and configure OJMS on the database. The user must have the necessary privileges to perform OJMS operations.
OJMS allows any database user to access queues in any schema, provided that the user has the appropriate access privileges. See "Create User and Assign Privileges". Create data sources or LDAP directory entries, if needed. Access the resource in your implementation through a JNDI lookup. After you have installed and configured this JMS provider, you must apply additional configuration. This includes the following:. Grant this user appropriate access privileges to perform OJMS operations.
Grant access privileges to this user to perform OJMS operations. The privileges that you need depend on what functionality you are requesting. The following example creates jmsuser , which must be created within its own schema, with privileges required for OJMS operations. You may need to grant other privileges, such as two-phase commit or system administration privileges, based on what the user needs.
For our example, OJMS requires the following methods:. In OJMS, both topics and queues use a queue table. Thus, is always false for a queue and true for a topic. Create the JMS Destination.
If you are creating a topic, you must add each subscriber for the topic. The JMS example requires a single queue— demoQueue. The following command creates a queue called demoQueue within the queue table demoTestQTab. After creation, the queue is started. If you want to add a topic, then the following example shows how you can create a topic called demoTopic within the topic table demoTestTTab.
After creation, two durable subscribers are added to the topic. Finally, the topic is started, and a user is granted a privilege to it. This brings you to the following page:. A row is added in which you can specify the name for each JNDI property and its value. Doing this configures only the providers; it does not configure the Destination objects topic, queue, and subscription.
To configure a JMS provider only for a specific application, select the application from the Applications page, scroll down to the Resources column, and select JMS Providers.
The screens that appear are the same as for the default JMS provider. If this is to be the JMS provider for all applications global , configure the global application. If this is to be the JMS provider for a single application local , configure the orion-application.
OjmsContext class, which is configured in the class attribute. The topic or queue connects to this data source to access the tables and queues that facilitate the messaging. With OJMS and accessing AQ in the database, the resource provider must be configured using either a data sources property or a URL property, as discussed in the following sections:.
Use a data source when the application runs within OC4J. To use a data source, first you must configure it within the data-sources. The JMS topics and queues use database tables and queues to facilitate messaging. The type of data source you use depends on the functionality you want. To support a two-phase commit transaction, use a nonemulated data source. For differences between emulated and nonemulated data sources, see "Defining Data Sources".
Customize this data source to match your environment. For example, substitute the host name, port, and SID of your database for myhostorcl.
Next, configure the resource provider using the data source name. For details on configuring data sources, see "Defining Data Sources". In this release, the data source is not serializable. The following demonstrates a URL configuration:. The only difference is the name of the resource provided in the JNDI lookup. The user-defined name can be anything and does not match any other configuration. The bean class must be defined as public not final or abstract.
The bean class must implement the javax. MessageDrivenBean and javax. MessageListener interfaces, which include the following:. The bean class must implement the container callback methods that normally match methods in the EJB home interface. Remote, local, and home interfaces are not implemented with an MDB. However, some of the callback methods required for these interfaces are implemented in the bean implementation.
These methods include the following:. The queue is identified in the deployment descriptors and the JMS configuration. In the onMessage method, the MDB creates a new message to be sent to the client.
Then, it sets the reply destination and sends the new message to the JMS client. This example shows how to receive a message from a queue and send out a response. You can receive a message in several ways. This example uses the methods of the Message object to retrieve all attributes of the message. Retrieve the QueueConnectionFactory object. Once the session is set up, then create a sender that uses the session through the createSender method of the QueueSession object.
Once the sender is created, you can send any message using the send method of the QueueSender object. This example puts together a response from the received message and then use the sender to send out that response.
Active 3 years, 6 months ago. Viewed 6k times. Improve this question. JoshMc 9, 2 2 gold badges 16 16 silver badges 36 36 bronze badges. Pawel Pawel 75 2 2 silver badges 5 5 bronze badges. Add a comment. Active Oldest Votes. I think you need three jars com. Improve this answer.
Stroboskop Stroboskop 4, 5 5 gold badges 33 33 silver badges 50 50 bronze badges. While you can get it to work using just the jar files, this method is brittle, not supported and cannot meet regulatory compliance requirements notably PCI but others as well. If any of these things are issues, the best approach is to download and install the WebSphere MQ client. It is free and available at bit.
RivieraKid 5, 4 4 gold badges 36 36 silver badges 47 47 bronze badges. Rob T.
0コメント