MQ Using Java PDF
MQ Using Java PDF
Using Java
SC34-6066-00
WebSphere MQ
Using Java
SC34-6066-00
Note!
Before using this information and the product it supports, be sure to read the general information under Appendix J,
Notices on page 441.
Contents
Figures . . . . . . . . . . . . . . . ix
Tables . . . . . . . . . . . . . . . xi
|
|
|
|
. .
. .
book
. .
. xiii
. xiii
xiii
. xiv
Summary of changes . . . . . . . . xv
| Changes for this edition (SC34-6066-00) . . . . . xv
| Chapter 2. Installation . . . . . . . .
| What is installed . . . . . . . . . . . .
Installation directories . . . . . . . . .
|
Environment variables . . . . . . . . .
|
| Web server configuration . . . . . . . . .
| Running WebSphere MQ Java applications under
| the Java 2 Security Manager . . . . . . . .
. 3
.
.
.
.
.
.
3
3
4
5
5
6
. 7
. 7
. 8
. 8
. 10
. 10
. 13
. 13
. 14
.
.
.
.
15
15
15
16
.
.
.
.
.
.
18
18
20
20
23
24
. 26
.
.
.
.
.
.
.
.
.
.
.
.
.
27
27
27
28
29
30
31
32
32
34
35
35
36
36
36
Signon . . . . . . . . . . . . . .
Sending a postcard . . . . . . . . . .
JMS Postcard configuration . . . . . . .
How JMS Postcard works . . . . . . .
Post installation setup . . . . . . . . . .
Additional setup for publish/subscribe mode .
Queues that require authorization for
non-privileged users . . . . . . . . .
Using the sample JMS applet to verify the TCP/IP
client . . . . . . . . . . . . . . .
Using the sample applet with OS/400 . . .
Running the sample applet . . . . . . .
Running the point-to-point IVT . . . . . . .
Point-to-point verification without JNDI . . .
Point-to-point verification with JNDI . . . .
IVT error recovery . . . . . . . . . .
The publish/subscribe installation verification test
Publish/subscribe verification without JNDI .
Publish/subscribe verification with JNDI . .
PSIVT error recovery . . . . . . . . .
Running your own WebSphere MQ JMS programs
Solving problems . . . . . . . . . . .
Tracing programs . . . . . . . . . .
Logging . . . . . . . . . . . . .
. . .
. . .
. . .
. . .
Server
. . .
. . .
. . .
. . .
. . .
. . .
. . .
. . .
. . .
. . .
. . .
.
.
.
.
39
40
41
41
.
.
.
.
.
.
.
.
.
.
.
42
42
43
43
43
45
45
46
51
53
54
.
.
.
.
.
.
.
.
.
.
.
.
57
58
58
59
iii
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MQChannelDefinition . . . .
Variables . . . . . . .
Constructors . . . . . .
MQChannelExit . . . . . .
Variables . . . . . . .
Constructors. . . . . .
MQDistributionList . . . .
Constructors. . . . . .
Methods . . . . . . .
MQDistributionListItem . . .
Variables . . . . . . .
Constructors. . . . . .
MQEnvironment . . . . .
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQException . . . . . .
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQGetMessageOptions . . .
Variables . . . . . . .
Constructors. . . . . .
MQManagedObject . . . .
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQMessage . . . . . . .
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQMessageTracker . . . .
Variables . . . . . . .
MQPoolServices . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQPoolServicesEvent . . .
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQPoolToken . . . . . .
Constructors. . . . . .
MQProcess . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQPutMessageOptions . . .
Variables . . . . . . .
Constructors. . . . . .
MQQueue . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQQueueManager . . . .
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQSimpleConnectionManager
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
61
61
61
62
62
62
62
65
67
67
68
68
69
70
71
72
72
73
74
|
. 75
. 76
. 78
.
.
.
.
.
.
79
79
80
81
82
82
.
.
.
.
83
83
84
85
. 86
. 86
86
. 86
Chapter 8. Environment-dependent
behavior . . . . . . . . . . . . . . 89
Core details . . . . . . . . . . . . .
Restrictions and variations for core classes . . .
MQGMO_* values . . . . . . . . . .
MQPMO_* values . . . . . . . . . .
MQPMRF_* values . . . . . . . . . .
MQCNO_FASTPATH_BINDING . . . . .
MQRO_* values . . . . . . . . . . .
Miscellaneous differences with z/OS & OS/390
Features outside the core . . . . . . . . .
MQQueueManager constructor option . . .
MQQueueManager.begin() method . . . .
MQGetMessageOptions fields . . . . . .
Distribution lists. . . . . . . . . . .
MQPutMessageOptions fields . . . . . .
MQMD fields. . . . . . . . . . . .
iv
.
.
.
.
.
.
.
.
.
.
.
.
.
.
89
90
90
90
90
90
91
91
92
92
92
92
92
93
93
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. 96
. 96
. 97
. 98
. 98
. . . . . . . 100
. . . . . . . 101
. . . . . . . 101
. . . . . . . 101
. . . . . . . 103
. . . . . . . 103
. . . . . . . 103
. . . . . . . 104
. . . . . . . 105
. . . . . . . 108
. . . . . . . 108
. . . . . . . 110
. . . . . . . 110
. . . . . . . 110
. . . . . . . 111
. . . . . . . 112
. . . . . . . 112
. . . . . . . 115
. . . . . . . 116
. . . . . . . 116
. . . . . . . 117
. . . . . . . 117
. . . . . . . 119
. . . . . . . 119
. . . . . . . 127
. . . . . . . 127
. . . . . . . 137
. . . . . . . 137
. . . . . . . 139
. . . . . . . 139
. . . . . . . 139
. . . . . . . 140
. . . . . . . 140
. . . . . . . 140
. . . . . . . 141
. . . . . . . 142
. . . . . . . 142
. . . . . . . 143
. . . . . . . 143
. . . . . . . 143
. . . . . . . 145
. . . . . . . 145
. . . . . . . 147
. . . . . . . 148
. . . . . . . 148
. . . . . . . 148
. . . . . . . 156
. . . . . . . 156
. . . . . . . 156
. . . . . . . 159
. . . . . . . 169
. . . . . . . 169
. . . . . . . 169
. . . . . . . 169
MQC . . . . . . . . .
MQPoolServicesEventListener .
Methods . . . . . . .
MQConnectionManager . . .
MQReceiveExit . . . . . .
Methods . . . . . . .
MQSecurityExit . . . . .
Methods . . . . . . .
MQSendExit. . . . . . .
Methods . . . . . . .
ManagedConnection . . . .
Methods . . . . . . .
ManagedConnectionFactory .
Methods . . . . . . .
ManagedConnectionMetaData .
Methods . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
171
172
172
173
174
174
176
176
178
178
180
180
183
183
185
185
|
|
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
189
190
190
191
191
192
193
193
195
195
196
196
197
197
198
198
198
198
199
199
203
203
203
204
205
207
207
209
209
209
209
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
210
210
210
212
213
214
214
214
214
215
215
217
219
219
220
222
223
223
225
229
230
233
234
239
240
241
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
243
243
244
248
249
251
251
252
253
253
254
255
256
256
256
257
258
259
260
261
. 264
Contents
BytesMessage . . . . . .
Methods . . . . . . .
Cleanup * . . . . . . .
WebSphere MQ constructor.
Methods . . . . . . .
Connection . . . . . . .
Methods . . . . . . .
ConnectionConsumer. . . .
Methods . . . . . . .
ConnectionFactory. . . . .
WebSphere MQ constructor.
Methods . . . . . . .
ConnectionMetaData . . . .
WebSphere MQ constructor.
Methods . . . . . . .
DeliveryMode . . . . . .
Fields . . . . . . . .
Destination . . . . . . .
WebSphere MQ constructors
Methods . . . . . . .
ExceptionListener . . . . .
Methods . . . . . . .
MapMessage . . . . . .
Methods . . . . . . .
Message . . . . . . . .
Fields . . . . . . . .
Methods . . . . . . .
MessageConsumer . . . .
Methods . . . . . . .
MessageListener . . . . .
Methods . . . . . . .
MessageProducer . . . . .
WebSphere MQ constructors
Methods . . . . . . .
MQQueueEnumeration * . .
Methods . . . . . . .
ObjectMessage . . . . . .
Methods . . . . . . .
Queue . . . . . . . . .
WebSphere MQ constructors
Methods . . . . . . .
QueueBrowser . . . . . .
Methods . . . . . . .
QueueConnection . . . . .
Methods . . . . . . .
QueueConnectionFactory . .
WebSphere MQ constructor.
Methods . . . . . . .
QueueReceiver . . . . . .
Methods . . . . . . .
QueueRequestor . . . . .
Constructors. . . . . .
Methods . . . . . . .
QueueSender . . . . . .
Methods . . . . . . .
QueueSession . . . . . .
Methods . . . . . . .
Session . . . . . . . .
Fields . . . . . . . .
Methods . . . . . . .
StreamMessage . . . . . .
vi
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
266
266
274
274
274
279
279
282
282
283
283
283
290
290
290
292
292
293
293
293
295
295
296
296
305
305
305
319
319
321
321
322
322
322
326
326
327
327
328
328
328
330
330
332
332
334
334
334
336
336
337
337
337
339
339
342
342
345
345
345
350
Methods . . . . . . .
TemporaryQueue . . . . .
Methods . . . . . . .
TemporaryTopic . . . . .
WebSphere MQ constructor.
Methods . . . . . . .
TextMessage . . . . . . .
Methods . . . . . . .
Topic . . . . . . . . .
WebSphere MQ constructor.
Methods . . . . . . .
TopicConnection . . . . .
Methods . . . . . . .
TopicConnectionFactory . . .
WebSphere MQ constructor.
Methods . . . . . . .
TopicPublisher . . . . . .
Methods . . . . . . .
TopicRequestor . . . . . .
Constructors. . . . . .
Methods . . . . . . .
TopicSession. . . . . . .
WebSphere MQ constructor.
Methods . . . . . . .
TopicSubscriber. . . . . .
Methods . . . . . . .
XAConnection . . . . . .
XAConnectionFactory . . .
XAQueueConnection . . . .
Methods . . . . . . .
XAQueueConnectionFactory .
Methods . . . . . . .
XAQueueSession . . . . .
Methods . . . . . . .
XASession . . . . . . .
Methods . . . . . . .
XATopicConnection . . . .
Methods . . . . . . .
XATopicConnectionFactory . .
Methods . . . . . . .
XATopicSession. . . . . .
Methods . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
350
358
358
359
359
359
360
360
361
361
361
364
364
367
367
367
373
373
376
376
376
378
378
378
382
382
383
384
385
385
386
386
388
388
389
389
391
391
393
393
395
395
configuration
. . . . .
. . . . .
details . . .
.
.
.
.
.
.
.
.
.
.
.
.
403
404
405
406
.
.
. 406
. 406
.
.
. 407
. 407
.
.
. 413
. 413
. 414
.
.
.
.
.
.
.
.
.
.
.
.
.
.
414
414
414
414
415
416
416
.
.
.
.
.
.
.
.
. 419
. 420
421
421
422
422
423
423
427
. 442
Index . . . . . . . . . . . . . . . 445
Sending your comments to IBM . . . 451
Contents
vii
viii
Figures
1.
2.
3.
4.
5.
6.
7.
. 241
. 250
409
ix
Tables
|
|
|
|
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
| 49.
239
239
240
254
255
257
258
261
263
264
265
399
401
404
404
404
405
405
405
405
406
406
406
425
xi
xii
xiii
xiv
Summary of changes
This section describes changes in this edition of WebSphere MQ Using Java. Changes
since the previous edition of the book are marked by vertical lines to the left of the
changes.
|
|
|
|
|
|
|
xv
Changes
xvi
| Chapter 2. Installation . . . . . . . . . .
| What is installed . . . . . . . . . . . .
Installation directories . . . . . . . . .
|
Environment variables . . . . . . . . .
|
| Web server configuration . . . . . . . . .
| Running WebSphere MQ Java applications under
| the Java 2 Security Manager . . . . . . . .
. 7
. 7
. 8
. 8
. 10
. 10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
. 25
. 26
.
.
.
.
.
.
.
.
.
.
.
.
.
.
27
27
27
28
28
29
30
31
32
32
34
35
35
36
36
36
Connection options
Programmable options allow WebSphere MQ Java to connect to WebSphere MQ in
either of the following ways:
v As a WebSphere MQ client using Transmission Control Protocol/Internet
Protocol (TCP/IP)
v In bindings mode, connecting directly to WebSphere MQ
Table 1 on page 5 shows which of these connection modes can be used for each
platform.
In addition, WebSphere MQ JMS publish/subscribe applications can connect
directly across TCP/IP to the IBM WebSphere MQ Event Broker program. For
more information about this connection see Chapter 11, Programming
publish/subscribe applications on page 203.
Connections
Table 1. Platforms and connection modes
Server platform
Standard Client
Bindings
yes
yes
yes
yes
yes
yes
yes
yes
OS/400
yes
yes
yes
yes
no
yes
Linux on Intel
yes
yes
yes
no
Windows NT
Windows 2000
AIX
HP-UX
Linux on zSeries
Notes:
1. HP-UX Java bindings support is available only for HP-UXv11 systems running
the POSIX draft 10 pthreaded version of WebSphere MQ.
2. On Linux on zSeries and Windows 98, only TCP/IP client connectivity is
supported.
The following sections describe these options in more detail.
Client connection
To use WebSphere MQ Java as a WebSphere MQ client, you can install it either on
the WebSphere MQ server machine, which may also contain a Web server, or on a
separate machine. If you install WebSphere MQ Java on the same machine as a
Web server, an advantage is that you can download and run WebSphere MQ client
applications on machines that do not have WebSphere MQ Java installed locally.
Wherever you choose to install the client, you can run it in three different modes:
From within any Java-enabled Web browser
In this mode, the locations of the WebSphere MQ queue managers that can
be accessed may be constrained by the security restrictions of the browser
that is used.
Using an appletviewer
To use this method, you must have the Java Development Kit (JDK) or
Java Runtime Environment (JRE) installed on the client machine.
As a standalone Java program or in a Web application server
To use this method, you must have the Java Development Kit (JDK) or
Java Runtime Environment (JRE) installed on the client machine.
Bindings connection
When used in bindings mode, WebSphere MQ Java uses the Java Native Interface
(JNI) to call directly into the existing queue manager API, rather than
communicating through a network. This provides better performance for
WebSphere MQ applications than using network connections. Unlike the client
mode, applications that are written using the bindings mode cannot be
downloaded as applets.
Connections
To use the bindings connection, WebSphere MQ Java must be installed on the
WebSphere MQ server.
Prerequisites
To run WebSphere MQ base Java, you require the following software:
v WebSphere MQ for the server platform you wish to use.
v Java Development Kit (JDK) for the server platform.
v Java Development Kit, or Java Runtime Environment (JRE), or Java-enabled Web
browser for client platforms. (See Client connection on page 5.)
v For z/OS & OS/390, OS/390 Version 2 Release 9 or higher, or z/OS, with UNIX
System Services (USS).
v For OS/400, the iSeries Developer Kit for Java, 5769-JV1, and the Qshell
Interpreter, OS/400 (5769-SS1) Option 30.
The following list shows the supported Java 2 Software Development Kits and Java
Runtime Environments:
v IBM Developer Kit for AIX, Java Technology Edition, Version 1.3.1
v IBM Developer Kit for Linux, Java Technology Edition, Version 1.3.1.
Some limitations apply to the Linux environment.
|
|
|
|
|
|
|
v IBM Developer Kit for OS/390, Java Technology Edition, Version 1.3.1
v IBM Developer Kit for Windows, Java Technology Edition, Version 1.3.1
|
|
|
|
|
For full provision of Secure Socket Layer (SSL) authentication to enable WebSphere
MQ Java and Java Message Service (JMS) applications to benefit from secure
connection to the queue manager (authentication, message integrity, data
encryption), a Java Runtime Environment at Version 1.4.0 is required for your
platform.
|
|
Please check the README file for the latest information about operating system
levels this product has been tested against.
To use the WebSphere MQ JMS administration tool (see Chapter 5, Using the
WebSphere MQ JMS administration tool on page 39), you require the following
additional software:
v At least one of the following service provider packages:
Lightweight Directory Access Protocol (LDAP) - ldap.jar, providerutil.jar.
File system - fscontext.jar, providerutil.jar.
v A Java Naming and Directory Service (JNDI) service provider. This is the
resource that stores physical representations of the administered objects. Users of
WebSphere MQ JMS will probably use an LDAP server for this purpose, but the
tool also supports the use of the file system context service provider. If an LDAP
server is used, it must be configured to store JMS objects. For information to
assist with this configuration, refer to Appendix C, LDAP schema definition for
storing Java objects on page 403.
To use the XOpen/XA facilities of WebSphere MQ JMS on OS/400 you need a
specific PTF. Please check the README file for further information.
|
|
|
|
|
Chapter 2. Installation
This chapter describes how the WebSphere MQ classes for Java and WebSphere
MQ classes for Java Message Service code is installed.
What is installed
|
|
|
The latest versions of both WebSphere MQ base Java and WebSphere MQ JMS
(together known as WebSphere MQ Java) are installed with WebSphere MQ. You
may need to override default installation options to make sure this is done.
|
|
|
|
Refer to the following books for more information about installing WebSphere MQ:
WebSphere MQ for AIX, V5.3 Quick Beginnings for AIX
WebSphere MQ for HP-UX, V5.3 Quick Beginnings for HP-UX
WebSphere MQ for iSeries V5.3 Quick Beginnings for OS/400
|
|
|
|
|
WebSphere MQ for Linux for Intel and Linux for zSeries, V5.3 Quick Beginnings for
Linux
WebSphere MQ for Solaris, V5.3 Quick Beginnings for Solaris
WebSphere MQ for Windows, V5.3 Quick Beginnings for Windows systems
WebSphere MQ for z/OS System Setup Guide for z/OS
|
|
com.ibm.mq.jar
|
|
|
|
com.ibm.mqbind.jar
com.ibm.mqjms.jar
|
|
The following Java libraries from Sun Microsystems are redistributed with the
WebSphere MQ JMS product:
connector.jar
Version 1.0
fscontext.jar
jms.jar
Version 1.0.2
jndi.jar
ldap.jar
providerutil.jar
Version 1.0
|
|
When installation is complete, files and samples are installed in the locations
shown in Installation directories on page 8.
|
|
What is installed
Note: Take care if you install the product, then subsequently install or reinstall a
version of SupportPac MA88. This may cause your WebSphere MQ Java
support to revert to an earlier level.
|
|
|
Installation directories
|
|
The WebSphere MQ Java V5.3 files are installed in the directories shown in Table 2.
Platform
Directory
AIX
/usr/mqm/java/
install_dir/mqm/java/
/QIBM/ProdData/mqm/java/
/opt/mqm/java/
Linux
install_dir/mqm/java/
Windows systems
|
|
|
Note: install_dir is the directory in which you installed the product. On Linux, this is likely
to be /opt and on z/OS & OS/390 it is likely to be /usr/lpp.
|
|
|
|
Some sample programs, such as the Installation Verification Programs (IVP), are
supplied. Table 3 lists the directory path to these on different platforms. WebSphere
MQ base Java samples are within a subdirectory base and WebSphere MQ JMS
samples are within a subdirectory jms.
Platform
Directory
AIX
/usr/mqm/samp/java/
install_dir/mqm/java/samples/
/QIBM/ProdData/mqm/java/samples/
/opt/mqm/samp/java/
Linux
install_dir/mqm/samp/java/
|
|
Windows systems
\Program Files\IBM\WebSphere
MQ\tools\Java\
|
|
|
Note: install_dir is the directory in which you installed the product. On Linux, this is likely
to be /opt and on z/OS & OS/390 it is likely to be /usr/lpp.
Environment variables
|
|
|
|
|
|
|
|
|
|
|
|
Installation directories
|
Platform
Sample CLASSPATH
|
|
|
|
AIX
CLASSPATH=/usr/mqm/java/lib/com.ibm.mq.jar:
/usr/mqm/java/lib/connector.jar:
/usr/mqm/java/lib:
/usr/mqm/samp/java/base:
|
|
|
|
HP-UX and
Sun Solaris
CLASSPATH=/opt/mqm/java/lib/com.ibm.mq.jar:
/opt/mqm/java/lib/connector.jar:
/opt/mqm/java/lib:
/opt/mqm/samp/java/base:
|
|
|
|
|
|
|
|
CLASSPATH=install_dir2/mqm/java/lib/com.ibm.mq.jar:
install_dir/mqm/java/lib/connector.jar:
install_dir/mqm/java/lib:
install_dir/mqm/java/samples/base:
|
|
|
|
CLASSPATH=/QIBM/ProdData/mqm/java/lib/com.ibm.mq.jar:
/QIBM/ProdData/mqm/java/lib/connector.jar:
/QIBM/ProdData/mqm/java/lib:
/QIBM/ProdData/mqm/java/samples/base:
|
|
|
|
Linux
CLASSPATH=install_dir2/mqm/java/lib/com.ibm.mq.jar:
install_dir/mqm/java/lib/connector.jar:
install_dir/mqm/java/lib:
install_dir/mqm/samp/java/base:
|
|
|
|
|
Notes:
|
|
To use WebSphere MQ JMS, you must include additional jar files in the classpath.
These are listed in Post installation setup on page 23.
|
|
|
|
|
1. mq_root_dir stands here for the directory used to install WebSphere MQ on Windows
systems. This is normally C:\Program Files\IBM\WebSphere MQ\.
2. install_dir is the directory in which you installed the product
Chapter 2. Installation
Installation directories
|
Platform
Environment variable
AIX
LD_LIBRARY_PATH=/usr/mqm/java/lib
HP-UX
SHLIB_PATH=/opt/mqm/java/lib
Sun Solaris
LD_LIBRARY_PATH=/opt/mqm/java/lib
LIBPATH=install_dir/mqm/java/lib
Linux
LD_LIBRARY_PATH=install_dir/mqm/java/lib
|
|
Notes:
1. To use WebSphere MQ Bindings for Java on OS/400, ensure that the library
QMQMJAVA is in your library list.
2. Ensure that you append the WebSphere MQ variables and do not overwrite
any of the existing system environment variables. If you overwrite existing
system environment variables, the application might fail during compilation or
at runtime.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If you install WebSphere MQ Java on a Web server, you can download and run
WebSphere MQ Java applications on machines that do not have WebSphere MQ
Java installed locally. To make the WebSphere MQ Java files accessible to your Web
server, you must set up your Web server configuration to point to the directory
where the client is installed. Consult your Web server documentation for details of
how to configure this.
|
|
|
Note: On z/OS & OS/390, the installed classes do not support client connection
and cannot be usefully downloaded to clients. However, jar files from
another platform can be transferred to z/OS & OS/390 and served to clients.
|
|
|
|
|
|
WebSphere MQ Java supports operation with the Java 2 Security Manager enabled.
To successfully run applications with the Security Manager enabled, you must
configure your JVM with a suitable policy definition file.
|
|
|
|
The simplest way to do this is to change the policy file supplied with the JRE. On
most systems this file is stored in the path lib/security/java.policy, relative to
your JRE directory. Policy files can be edited by hand or using the policytool
program supplied with your JRE.
|
|
The changes that need to be made are to give authority to the com.ibm.mq.jar and
com.ibm.mqjms.jar files so they can:
v Create sockets (in client mode)
v Load the native library (in bindings mode)
v Read various properties from the environment
|
|
|
10
Here is an example of a policy file entry which will allow the WebSphere MQ Java
to run successfully under the default security manager. The string /opt/mqm in
this example should be replaced with the location where WebSphere MQ Java is
installed on your system.
|
|
|
This example of a policy file will enable the WebSphere MQ Java classes to work
correctly under the security manager, but you may still need to enable your own
code to run correctly before your applications will work.
|
|
|
The sample code shipped with WebSphere MQ Java has not been specifically
enabled for use with the security manager; however the IVT tests do run with the
above policy file and the default security manager in place.
Chapter 2. Installation
11
12
TCP/IP client
1. Define a server connection channel using the following procedures:
For the OS/400 platform:
a. Start your queue manager by using the STRMQM command.
b. Define a sample channel called JAVA.CHANNEL by issuing the
following command:
CRTMQMCHL CHLNAME(JAVA.CHANNEL) CHLTYPE(*SVRCN) MQMNAME(QMGRNAME)
MCAUSERID(SOMEUSERID)
TEXT(Sample channel for WebSphere MQ classes for Java)
13
Note: If you use the default queue manager, you can omit the -m
option.
For UNIX operating systems:
Configure the inetd daemon, so that the inetd starts the WebSphere MQ
channels. See WebSphere MQ Clients for instructions on how to do this.
For the OS/400 operating system:
Issue the command:
STRMQMLSR MQMNAME(QMGRNAME)
3. Type:
java MQIVP
14
:
:
:
:
ipaddress(1)
(1414)(2)
channelname(2)
qmname
Notes:
1. If you choose server connection, you do not see the prompts marked (2).
2. On z/OS & OS/390, leave the field blank at prompt (1).
3. On OS/400, you can run the command java MQIVP only from the Qshell
interactive interface (the Qshell is option 30 of OS/400, 5769-SS1). Alternatively,
you can run the application by using the CL command RUNJVA CLASS(MQIVP).
4. To use the WebSphere MQ bindings for Java on OS/400, you must ensure that
the library QMQMJAVA is in your library list.
15
Error messages
Error messages
Here are some of the more common error messages that you may see:
Unable to identify local host IP address
The server is not connected to the network.
Connect the server to the network and retry.
MQRC_ADAPTER_CONN_LOAD_ERROR
If you see this error while running on z/OS, ensure that the WebSphere
MQ SCSQANLE, and SCSQAUTH datasets are in your STEPLIB statement.
16
|
|
|
|
|
|
JMS Postcard
JMS Postcard is a simple, friendly way to do the following:
v Verify that you have successfully installed WebSphere MQ and WebSphere MQ
JMS on one computer and, optionally, others as well
v Introduce you to messaging
|
|
|
|
You must make sure that the Java Messaging feature of WebSphere MQ for
Windows (WebSphere MQ JMS) is installed to be able to use JMS Postcard. In turn,
WebSphere MQ JMS requires that you have a working Java Runtime Environment
(JRE) at Java 1.3 level.
|
|
|
|
|
Before you can successful run the JMS Postcard application, you must have defined
the environment variables CLASSPATH, LIBPATH, MQ_JAVA_INSTALL_PATH,
and MQ_JAVA_DATA_PATH. On Windows systems these variables are set as part
of the install process. On other platforms you must set them yourself. For more
information about these variables, see Environment variables on page 8.
|
|
|
|
Many operations that the Postcard application carries out on your behalf require
the user to be a member of the WebSphere MQ administrators group (mqm). If you
are not a member of mqm, get a member of the mqm group to set up the default
configuration on your behalf. See JMS Postcard default configuration on page 20.
Starting
|
|
To start the JMS Postcard application, run the postcard script. This is supplied in
the java/bin directory of the WebSphere MQ installation.
|
|
|
The first time JMS Postcard is run on a computer, you are asked to complete the
default configuration, which sets up a suitable queue manager to act as mailbox.
See JMS Postcard default configuration on page 20.
|
|
|
Whenever you start a Postcard application, you are asked to sign on and enter a
nickname. (There are advanced options available on the sign-on dialog, see
Signon advanced options on page 18 for details).
17
JMS Postcard
Signon
|
|
|
|
The sign-on dialog has a check box labelled Advanced. Check this to see the
extended dialog where you can choose which queue manager is used by the
Postcard program.
|
|
|
|
|
|
Notes:
1. If you have no queue managers at all, or just the default configuration, then the
checkbox will be disabled.
2. Depending upon what queue managers and clusters you have, the checkbox
and options will be in one of various combinations of enabled, disabled, and
preselected.
|
|
|
|
|
|
|
|
|
|
|
|
Sending a postcard
|
|
|
|
|
|
To send a postcard successfully, you need to have two instances of the Postcard
application with different nicknames. For example, suppose you start the Postcard
application and use the nickname Will, and then start it again using the
nickname Tim. Will can send postcards to Tim and Tim can send postcards to
Will.
|
|
If Will and Tim are connected to the same queue manager, see Running JMS
Postcard with one queue manager.
|
|
|
|
|
When the postcard arrives successfully, you know your WebSphere MQ installation
and your WebSphere MQ JMS are working correctly.
|
|
|
|
|
|
|
|
|
18
JMS Postcard
|
|
|
|
|
|
|
|
|
|
5. Look in Tims Postcard to see the message arrive, and double-click on it to see
the postcard itself.
6. Try using Tim to send a message back to Will. You can do this easily, by
selecting the message that arrived in Tims list, and clicking the Reply button.
Note: See JMS Postcard configuration on page 20 for advice about configuration.
|
|
|
|
|
|
|
|
|
|
|
|
This assumes that you have already started JMS Postcard with a nickname, for
example Will, and you want to send a postcard to a second nickname on a
second queue manager on this, or another, computer.
1. Start the second Postcard, choosing one of the following:
v JMS Postcard
on this computer:
run the postcard shell script again, then in the sign-on dialog check
Advanced and select the second queue manager you want to use.
on another computer:
run the postcard shell script; or, on Windows systems, open WebSphere
MQ First Steps and click on JMS Postcard.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Look in Tims Postcard to see the message arrive, and double-click on it to see
the postcard itself.
5. Try sending a message from Tims computer back to Will.
You can do this easily, by selecting the message that arrived in Tims list, and
clicking the Reply button.
Chapter 4. Using WebSphere MQ classes for Java Message Service (WebSphere MQ JMS)
19
JMS Postcard
|
|
|
|
|
The Postcard application needs a suitable queue manager to act as mailbox. See
JMS Postcard default configuration for the easiest way to get one. You will be
prompted to install this default configuration the first time you start the Postcard
application (see Starting on page 17).
|
|
Instead of using the default configuration, you can also start the Postcard
application using any other local queue manager.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
On platforms other than Windows systems, you can also run the
DefaultConfiguration script, provided that there are no existing queue managers
on this computer. On Windows systems, run Default Configuration from First
Steps.
|
|
|
|
Installing the default configuration quickly and easily creates a special queue
manager (with queues and channels), and optionally joins it to a cluster, to enable
you to use the JMS Postcard application to verify your installation and see
messaging working.
|
|
|
|
|
Starting up
|
|
|
|
|
|
|
Receiving messages
|
|
|
|
When JMS Postcard starts, it checks to see what queue managers exist on this
computer, and initializes the sign-on dialog accordingly. If there are no queue
managers at all, it will prompt you to install the default configuration.
All the time JMS Postcard is running, it polls a queue called postcard for incoming
messages from other Postcard applications. If there is no queue called postcard,
JMS Postcard will attempt to create one.
20
JMS Postcard
|
|
|
client should only receive messages where the CorrelId field matches the nickname
of the user. The words from the message data are then presented in the JMS
Postcard window.
|
|
|
Sending messages
|
|
|
If you did enter a name, postcard checks for the existence of a queue manager
with this name - first using the exact name supplied, and then using a prefix in the
same format as that created by the default configuration.
|
|
|
|
|
Finally it builds a JMS BytesMessage from your nickname and the words you
typed in, and runs queueSender.send(theMessage) to put the message onto the
queue.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JMS Postcard can only send to another queue manager if a connection to that
queue manager exists. This connection will exist because either both queue
managers are members of the same cluster, or you have explicitly created a
connection yourself. JMS Postcard can therefore assume that the queue manager
will be connectable, and simply connects to it, opens the queue and puts a
message, as already described, leaving all the work of getting the message there to
the WebSphere MQ cluster code. In other words, JMS Postcard uses only the one
piece of code for putting the message, and does not need to know whether or not
the message is going to another computer.
|
|
|
|
|
|
|
|
The channel may be discarded afterwards, if the cluster optimizing code does not
need it. If the queue managers are on different computers, that is all handled by
the cluster code.
|
|
|
|
|
|
|
|
|
|
If you did not enter a computer name in the On: field, then JMS Postcard assumes
the recipient is on the same queue manager.
When other instances of Postcard on this computer are using the same queue
manager and queue, the messages are simply being put and got from the one
queue. This does, however, verify that the WebSphere MQ code installed on this
computer is configured and working correctly.
If you sent a postcard message to John, but never ran a Postcard application
with the nickname John, the message would sit on the queue for ever. To
prevent this, JMS Postcard sets the Message Lifetime (Expiry) field in the Message
Descriptor (MQMD) to 48 hours. After that time, the message will be discarded,
wherever it may be (possibly even still in transmission).
You can exchange messages between all the different types of Postcard application
as follows:
Chapter 4. Using WebSphere MQ classes for Java Message Service (WebSphere MQ JMS)
21
JMS Postcard
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Edit the sample file postcard.ini in the bin directory of the WebSphere MQ
classes for Java installation and set your preferred settings for font size, and screen
foreground and background colors.
|
|
|
Note: The precise use of upper and lower case letters in the keywords, as in the
following examples, must be strictly observed when you set these
properties.
|
|
|
|
|
|
v
v
v
v
Normally JMS Postcard uses standard Java Swing settings for font size and
background color. But if a postcard.ini file is detected on startup, JMS Postcard
will use settings specified in this file instead. You can also change the trace setting.
Background=000000
Foreground=FFFFFF
|
|
|
|
|
|
MinimumFont=20
This example selects a minimum font size of 20 points. Any value smaller
than 13 is ignored.
|
|
|
|
WebBrowser=nautilus
|
|
|
|
|
Trace=1
Set this to start trace output. Note that the trace output is sent to the trc
subdirectory of the directory defined by the MQ_JAVA_DATA_PATH
system environment variable. If the application cannot write to this
directory, trace output is directed to the system console.
|
|
|
|
22
JMS Postcard
|
|
|
|
|
|
|
|
|
jndi.jar1
jta.jar
ldap.jar1
providerutil.jar
Environment variables
There are a number of scripts in the bin subdirectory of the WebSphere
MQ JMS installation. These are intended for use as convenient shortcuts
for a number of common actions. Many of these scripts assume that the
environment variables MQ_JAVA_INSTALL_PATH and MQ_JAVA_DATA_PATH are
defined, pointing to the directory in which WebSphere MQ JMS is installed
and a directory for log and trace output, respectively. If you do not set
these variables, you must edit the scripts in the bin directory accordingly.
On Windows NT, you can set the classpath and new environment variable by
using the Environment tab of the System Properties. On Windows 2000,
Environment is a button on the Advanced tab of System Properties. On UNIX,
these would normally be set from each users logon scripts. On any platform, you
can choose to use scripts to maintain different classpaths and other environment
variables for different projects.
1. For z/OS & OS/390, use ibmjndi.jar and jndi.jar from /usr/lpp/ldap/lib instead of jndi.jar and ldap.jar. These files are
supplied with the operating system.
Chapter 4. Using WebSphere MQ classes for Java Message Service (WebSphere MQ JMS)
23
WebSphere MQ Integrator V2
To verify that the broker provided in WebSphere MQ Integrator V2
is installed and running please refer to the product documentation.
The command to start the broker in WebSphere MQ Integrator V2
is:
mqsistart MYBROKER
24
SRCMBR(MQJMS_PSQ) SRCFILE(QGPL/QCLSRC)
If an error occurs, check that you typed the queue manager name correctly,
and check that the queue manager is running.
Chapter 4. Using WebSphere MQ classes for Java Message Service (WebSphere MQ JMS)
25
5. To operate the local queue manager to communicate with the remote broker,
take the following steps:
a. Start the local queue manager.
b. Start a listener for the local queue manager.
c. Start the sender and receiver channels to the remote broker queue manager.
26
or by pointing your Java 1.3 enabled browser at this web page. The string
<web.server.host/jmsapplet> should be changed as appropriate to the
URI of the web server you are using.
Running in appletviewer from the local machine:
The applet is invoked using a command line like the following:
appletviewer test.html
Chapter 4. Using WebSphere MQ classes for Java Message Service (WebSphere MQ JMS)
27
The JMS sample applet contains a main method that allows the applet to
run as a standalone Java application.
This option requires the WebSphere MQ base Java and WebSphere MQ
JMS libraries to be present in the system CLASSPATH, as for your own
WebSphere MQ JMS applications. It allows you to connect to any host and
queue manager to which you have TCP/IP access.
28
Point-to-point IVT
For client mode, to run the test without JNDI, issue the following command:
IVTRun [-t] -nojndi -client -m <qmgr> -host <hostname> [-port <port>]
[-channel <channel>]
where:
-t
qmgr
hostname
port
channel
If the test completes successfully, you should see output similar to the following:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5648-C60, 5724-B41, 5655-F10 (c) Copyright IBM Corp. 2002. All Rights Reserved.
Websphere MQ classes for Java(tm) Message Service 5.300
Installation Verification Test
Creating a QueueConnectionFactory
Creating a Connection
Creating a Session
Creating a Queue
Creating a QueueSender
Creating a QueueReceiver
Creating a TextMessage
Sending the message to SYSTEM.DEFAULT.LOCAL.QUEUE
Reading the message back again
Got message:
JMS Message class: jms_text
JMSType:
null
JMSDeliveryMode: 2
JMSExpiration:
0
JMSPriority:
4
JMSMessageID:
ID:414d51204153434152492020202020207cce883c03300020
JMSTimestamp:
1016124013892
JMSCorrelationID:null
JMSDestination: queue:///SYSTEM.DEFAULT.LOCAL.QUEUE
JMSReplyTo:
null
JMSRedelivered: false
JMS_IBM_PutDate:20020314
JMSXAppID:java
JMS_IBM_Format:MQSTR
JMS_IBM_PutApplType:6
JMS_IBM_MsgType:8
JMSXUserID:parkiw
JMS_IBM_PutTime:16401390
JMSXDeliveryCount:1
A simple text message from the MQJMSIVT program
Reply string equals original string
Closing QueueReceiver
Closing QueueSender
Chapter 4. Using WebSphere MQ classes for Java Message Service (WebSphere MQ JMS)
29
Point-to-point IVT
|
|
|
|
Closing Session
Closing Connection
IVT completed OK
IVT finished
This message means that either the server is not storing Java objects, or the
permissions on the objects or the suffix are not correct. See Checking your LDAP
server configuration on page 403.
Also, the following administered objects must be retrievable from a JNDI
namespace:
v MQQueueConnectionFactory
v MQQueue
A script, named IVTSetup on UNIX, or IVTSetup.bat on Windows NT, is provided
to create these objects automatically. Enter the command:
IVTSetup
The script invokes the WebSphere MQ JMS Administration tool (see Chapter 5,
Using the WebSphere MQ JMS administration tool on page 39) and creates the
objects in a JNDI namespace.
The MQQueueConnectionFactory is bound under the name ivtQCF (for LDAP,
cn=ivtQCF). All the properties are default values:
TRANSPORT(BIND)
PORT(1414)
HOSTNAME(localhost)
CHANNEL(SYSTEM.DEF.SVRCONN)
VERSION(1)
CCSID(819)
TEMPMODEL(SYSTEM.DEFAULT.MODEL.QUEUE)
QMANAGER()
The MQQueue is bound under the name ivtQ (cn=ivtQ). The value of the QUEUE
property becomes QUEUE(SYSTEM.DEFAULT.LOCAL.QUEUE). All other properties have
default values:
PERSISTENCE(APP)
QUEUE(SYSTEM.DEFAULT.LOCAL.QUEUE)
EXPIRY(APP)
TARGCLIENT(JMS)
ENCODING(NATIVE)
VERSION(1)
CCSID(1208)
PRIORITY(APP)
QMANAGER()
Once the administered objects are created in the JNDI namespace, run the IVTRun
(IVTRun.bat on Windows NT) script using the following command:
IVTRun [ -t ]
where:
-t
30
Point-to-point IVT
providerURL
If the test completes successfully, the output is similar to the non-JNDI output,
except that the create QueueConnectionFactory and Queue lines indicate retrieval
of the object from JNDI. The following shows an example.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5648-C60, 5724-B41, 5655-F10 (c) Copyright IBM Corp. 2002. All Rights Reserved.
Websphere MQ classes for Java(tm) Message Service 5.300
Installation Verification Test
Using administered objects, please ensure that these are available
Retrieving a QueueConnectionFactory from JNDI
Creating a Connection
Creating a Session
Retrieving a Queue from JNDI
Creating a QueueSender
Creating a QueueReceiver
Creating a TextMessage
Sending the message to SYSTEM.DEFAULT.LOCAL.QUEUE
Reading the message back again
Got message:
JMS Message class: jms_text
JMSType:
null
...
...
Although not strictly necessary, it is good practice to remove objects that are
created by the IVTSetup script from the JNDI namespace. A script called IVTTidy
(IVTTidy.bat on Windows NT) is provided for this purpose.
31
Point-to-point IVT
does not exist on your default queue manager, or the queue is not enabled for
PUT and GET. Add or enable the queue for the duration of the test.
Table 6 lists the classes that are tested by IVT, and the package that they come
from:
Table 6. Classes that are tested by IVT
Class
Jar file
com.ibm.mqjms.jar
com.ibm.mq.MQMessage
com.ibm.mq.jar
javax.jms.Message
jms.jar
javax.naming.InitialContext
jndi.jar
javax.resource.cci.Connection
connector.jar
javax.transaction.xa.XAException
jta.jar
com/sun/jndi/toolkit/ComponentDirContext
providerutil.jar
com.sun.jndi.ldap.LdapCtxFactory
ldap.jar
Create a
Create a
Use p to
Use s to
When you run the PSIVT, the publisher publishes the message, and the subscriber
receives and displays the message. The publisher publishes to the brokers default
stream. The subscriber is non-durable, does not perform message selection, and
accepts messages from local connections. It performs a synchronous receive,
waiting a maximum of 5 seconds for a message to arrive.
You can run the PSIVT, like the IVT, in either JNDI mode or standalone mode.
JNDI mode uses JNDI to retrieve a TopicConnectionFactory and a Topic from a
JNDI namespace. If JNDI is not used, these objects are created at runtime.
For client mode, to run the test without JNDI, issue the following command:
PSIVTRun -nojndi -client -m <qmgr> -host <hostname> [-port <port>]
[-channel <channel>] [-bqm <broker>] [-t]
32
Publish/subscribe IVT
where:
-nojndi
qmgr
hostname
port
channel
broker
-t
5648-C60, 5724-B41, 5655-F10 (c) Copyright IBM Corp. 2002. All Rights Reserved.
Websphere MQ classes for Java(tm) Message Service 5.300
Publish/Subscribe Installation Verification Test
Creating a Connection
Creating a TopicConnectionFactory
Creating a Session
Creating a Topic
Creating a TopicPublisher
Creating a TopicSubscriber
Creating a TextMessage
Adding text
Publishing the message to topic://MQJMS/PSIVT/Information
Waiting for a message to arrive [5 secs max]...
Got message:
JMS Message class: jms_text
JMSType:
null
JMSDeliveryMode: 2
JMSExpiration:
0
JMSPriority:
4
JMSMessageID:
ID:414d51204153434152492020202020207cce883c19230020
JMSTimestamp:
1016124933637
JMSCorrelationID:ID:414d51204153434152492020202020207cce883c09320020
JMSDestination: topic://MQJMS/PSIVT/Information
JMSReplyTo:
null
JMSRedelivered: false
JMS_IBM_PutDate:20020314
JMSXAppID:ASCARI
JMS_IBM_Format:MQSTR
JMS_IBM_PutApplType:26
JMS_IBM_MsgType:8
JMSXUserID:parkiw
JMS_IBM_PutTime:16553367
JMSXDeliveryCount:1
A simple text message from the MQJMSPSIVT program
Reply string equals original string
Closing TopicSubscriber
Closing TopicPublisher
Closing Session
Closing Connection
PSIVT finished
Chapter 4. Using WebSphere MQ classes for Java Message Service (WebSphere MQ JMS)
33
Publish/subscribe IVT
where:
-t
providerURL
If the test completes successfully, output is similar to the non-JNDI output, except
that the create QueueConnectionFactory and Queue lines indicate retrieval of the
object from JNDI.
34
Publish/subscribe IVT
this indicates that the broker is installed on the target queue manager, but its
control queue contains some outstanding messages. For instructions on how to
start it, see Additional setup for publish/subscribe mode on page 24.
v If the following message is displayed:
Unable to connect to queue manager: <default>
|
|
The utility provides default locations for the trace and log files, and enables you to
add any application runtime parameters that your application needs. The supplied
script assumes that the environment variable MQ_JAVA_INSTALL_PATH is set to
the directory in which the WebSphere MQ JMS is installed. The script also assumes
that the subdirectories trace and log within the directory pointed to by
MQ_JAVA_DATA_PATH are used for trace and log output, respectively.
Use the following command to run your application:
runjms <classname of application> [application-specific arguments]
Chapter 4. Using WebSphere MQ classes for Java Message Service (WebSphere MQ JMS)
35
Solving problems
Solving problems
If a program does not complete successfully, run the installation verification
program, which is described in Running the point-to-point IVT on page 28, and
follow the advice given in the diagnostic messages.
Tracing programs
The WebSphere MQ JMS trace facility is provided to help IBM staff to diagnose
customer problems.
Trace is disabled by default, because the output rapidly becomes large, and is
unlikely to be of use in normal circumstances.
If you are asked to provide trace output, you can enable it by setting the Java
property MQJMS_TRACE_LEVEL to one of the following values:
on
base
For example:
java -DMQJMS_TRACE_LEVEL=base MyJMSProg
The runjms utility script sets these properties by using the environment variables
MQJMS_TRACE_LEVEL and MQ_JAVA_DATA_PATH, as follows:
|
|
|
|
java -DMQJMS_LOG_DIR=%MQ_JAVA_DATA_PATH%\log
-DMQJMS_TRACE_DIR=%MQ_JAVA_DATA_PATH%\trace
-DMQJMS_TRACE_LEVEL=%MQJMS_TRACE_LEVEL% %1 %2 %3 %4 %5 %6 %7 %8 %9
Logging
The WebSphere MQ JMS log facility is provided to report serious problems,
particularly those that may indicate configuration errors rather than programming
errors. By default, log output is sent to the System.err stream, which usually
appears on the stderr of the console in which the JVM is run.
You can redirect the output to a file by using a Java property that specifies the new
location, for example:
java -DMQJMS_LOG_DIR=/mydir/forlogs MyJMSProg
The utility script runjms, in the bin directory of the WebSphere MQ JMS
installation, sets this property to:
|
<MQ_JAVA_DATA_PATH>/log
36
Logging
|
|
|
Chapter 4. Using WebSphere MQ classes for Java Message Service (WebSphere MQ JMS)
37
Logging
38
where:
-t
-v
-cfg config_filename
A command prompt is displayed, which indicates that the tool is ready to accept
administration commands. This prompt initially appears as:
InitCtx>
indicating that the current context (that is, the JNDI context to which all naming
and directory operations currently refer) is the initial context defined in the
PROVIDER_URL configuration parameter (see Configuration on page 40).
Copyright IBM Corp. 1997, 2002
39
Configuration
You must configure the administration tool with values for the following three
properties:
INITIAL_CONTEXT_FACTORY
This indicates the service provider that the tool uses. There are three
explicitly supported values for this property:
v com.sun.jndi.ldap.LdapCtxFactory (for LDAP)
v com.sun.jndi.fscontext.RefFSContextFactory (for file system context)
v com.ibm.websphere.naming.WsnInitialContextFactory (to work with
WebSphere Application Servers CosNaming repository)
On z/OS & OS/390, com.ibm.jndi.LDAPCtxFactory is also supported and
provides access to an LDAP server. However, note that it is incompatible
with com.sun.jndi.ldap.LdapCtxFactory, in that objects created using one
InitialContextFactory cannot be read or modified using the other.
You can also use an InitialContextFactory that is not in the list above. See
Using an unlisted InitialContextFactory on page 41 for more details.
PROVIDER_URL
This indicates the URL of the sessions initial context, the root of all JNDI
operations carried out by the tool. Three forms of this property are
currently supported:
v ldap://hostname/contextname (for LDAP)
v file:[drive:]/pathname (for file system context)
v iiop://hostname[:port] /[?TargetContext=ctx] (to access base
WebSphere Application Server CosNaming namespace)
SECURITY_AUTHENTICATION
This indicates whether JNDI passes over security credentials to your
service provider. This property is used only when an LDAP service
provider is used. This property can currently take one of three values:
v none (anonymous authentication)
v simple (simple authentication)
v CRAM-MD5 (CRAM-MD5 authentication mechanism)
If a valid value is not supplied, the property defaults to none. See
Security on page 41 for more details about security with the
administration tool.
These properties are set in a configuration file. When you invoke the tool, you can
specify this configuration by using the -cfg command-line parameter, as described
in Invoking the Administration tool on page 39. If you do not specify a
configuration file name, the tool attempts to load the default configuration file
(JMSAdmin.config). It looks for this file first in the current directory, and then in the
40
Configuration
<MQ_JAVA_INSTALL_PATH>/bin directory, where <MQ_JAVA_INSTALL_PATH> is the
path to your WebSphere MQ JMS installation.
The configuration file is a plain-text file that consists of a set of key-value pairs,
separated by an =. This is shown in the following example:
#Set the service provider
INITIAL_CONTEXT_FACTORY=com.sun.jndi.ldap.LdapCtxFactory
#Set the initial context
PROVIDER_URL=ldap://polaris/o=ibm_us,c=us
#Set the authentication type
SECURITY_AUTHENTICATION=none
(A # in the first column of the line indicates a comment, or a line that is not
used.)
The installation comes with a sample configuration file that is called
JMSAdmin.config, and is found in the <MQ_JAVA_INSTALL_PATH>/bin directory. Edit
this file to suit the setup of your system.
Security
Administrators need to know about the effect of the SECURITY_AUTHENTICATION
property described in Configuration on page 40.
v If this parameter is set to none, JNDI does not pass any security credentials to
the service provider, and anonymous authentication is performed.
v If the parameter is set to either simple or CRAM-MD5, security credentials are
passed through JNDI to the underlying service provider. These security
credentials are in the form of a user distinguished name (User DN) and
password.
|
|
If security credentials are required, then the user will be prompted for these when
the tool initializes. This can be avoided by setting the PROVIDER_USERDN and
PROVIDER_PASSWORD properties in the JMSAdmin configuration file.
|
|
Note: If you do not use these properties, the text typed, including the password, is
echoed to the screen. This may have security implications.
Chapter 5. Using the WebSphere MQ JMS administration tool
41
Configuration
The tool does no authentication itself; the task is delegated to the LDAP server. It
is the responsibility of the LDAP server administrator to set up and maintain
access privileges to different parts of the directory. If authentication fails, the tool
displays an appropriate error message and terminates.
More detailed information about security and JNDI is in the documentation at
Suns Java web site (http://java.sun.com).
Administration commands
When the command prompt is displayed, the tool is ready to accept commands.
Administration commands are generally of the following form:
verb [param]*
where verb is one of the administration verbs listed in Table 7. All valid commands
consist of at least one (and only one) verb, which appears at the beginning of the
command in either its standard or short form.
The parameters a verb may take depend on the verb. For example, the END verb
cannot take any parameters, but the DEFINE verb may take any number of
parameters from 1 to 20 or more. Details of the verbs that take at least one
parameter are discussed in later sections of this chapter.
Table 7. Administration verbs
42
Verb
Short form
Description
ALTER
ALT
DEFINE
DEF
DISPLAY
DIS
DELETE
DEL
CHANGE
CHG
COPY
CP
MOVE
MV
Administration commands
Table 7. Administration verbs (continued)
Verb
Short form
END
Description
Close the administration tool
Manipulating subcontexts
You can use the verbs CHANGE, DEFINE, DISPLAY and DELETE to manipulate directory
namespace subcontexts. Their use is described in Table 8.
Table 8. Syntax and description of commands used to manipulate subcontexts
Command syntax
Description
DEFINE CTX(ctxName)
DISPLAY CTX
DELETE CTX(ctxName)
CHANGE CTX(ctxName)
Object types
Table 9 on page 44 shows the eight types of administered objects. The Keyword
column shows the strings that you can substitute for TYPE in the commands shown
Chapter 5. Using the WebSphere MQ JMS administration tool
43
Keyword
Description
MQQueueConnectionFactory
QCF
MQTopicConnectionFactory
TCF
MQQueue
MQTopic
MQXAQueueConnectionFactory1
XAQCF
MQXATopicConnectionFactory1
XATCF
JMSWrapXAQueueConnectionFactory2 WSQCF
JMSWrapXATopicConnectionFactory2
WSTCF
1. These classes are provided for use by vendors of application servers. They are unlikely
to be directly useful to application programmers.
2. Use this style of ConnectionFactory if you wish your JMS sessions to participate in
global transactions that are coordinated by WebSphere Application Server.
44
Description
DISPLAY TYPE(name)
DELETE TYPE(name)
COPY TYPE(nameA)
TYPE(nameB)
MOVE TYPE(nameA)
TYPE(nameB)
Creating objects
Objects are created and stored in a JNDI namespace using the following command
syntax:
DEFINE TYPE(name) [property]*
That is, the DEFINE verb, followed by a TYPE(name) administered object reference,
followed by zero or more properties (see Properties on page 46).
45
cn=testQueue
com.ibm.mq.jms.MQQueue
1 Object(s)
0 Context(s)
1 Binding(s), 1 Administered
Note that although the object name supplied (testQueue) does not have a prefix,
the tool automatically adds one to ensure compliance with the LDAP naming
convention. Likewise, submitting the command DISPLAY Q(testQueue) also causes
this prefix to be added.
You may need to configure your LDAP server to store Java objects. Information to
assist with this configuration is provided in Appendix C, LDAP schema definition
for storing Java objects on page 403.
Properties
A property consists of a name-value pair in the format:
PROPERTY_NAME(property_value)
Property names are not case-sensitive, and are restricted to the set of recognized
names shown in Table 11. This table also shows the valid property values for each
property.
Table 11. Property names and valid values
46
Property
Short form
BROKERCCDSUBQ
CCDSUB
v SYSTEM.JMS.D.CC.SUBSCRIPTION.QUEUE
v Any string
BROKERCCSUBQ
CCSUB
v SYSTEM.JMS.ND.CC.SUBSCRIPTION.QUEUE
v Any string
BROKERCONQ
BCON
Any string
BROKERDURSUBQ
BDSUB
v SYSTEM.JMS.D.SUBSCRIPTION.QUEUE
v Any string
BROKERPUBQ
BPUB
v SYSTEM.BROKER.DEFAULT.STREAM
v Any string
BROKERQMGR
BQM
Any string
BROKERSUBQ
BSUB
v SYSTEM.JMS.ND.SUBSCRIPTION.QUEUE
v Any string
Short form
BROKERVER
BVER
CCSID
CCS
CHANNEL
CHAN
Any string
CLEANUP
CL
v
v
v
v
CLEANUPINT
CLINT
v 60000
v Any positive integer
CLIENTID
CID
Any string
DESCRIPTION
DESC
Any string
ENCODING
ENC
EXPIRY
EXP
HOSTNAME
HOST
v localhost
v Any string
MSGBATCHSZ
MBS
v 10
v Any positive integer
MSGRETENTION
MRET
SAFE
ASPROP
NONE
STRONG
PER
POLLINGINT
PINT
v 5000
v Any positive integer
PORT
PRIORITY
PRI
PUBACKINT
PAI
v 25
v Any positive integer
47
Short form
QMANAGER
QMGR
Any string
QUEUE
QU
Any string
RECEXIT
RCX
Any string
RECEXITINIT
RCXI
Any string
SECEXIT
SCX
Any string
SECEXITINIT
SCXI
Any string
SENDEXIT
SDX
Any string
SENDXITINIT
SDXI
Any string
|
|
SSLCIPHERSUITE
SCPHS
v Not set
v See SSL properties on page 53
|
|
|
SSLCRL
SCRL
v Not set
v Space-separated list of LDAP URLs. See SSL
properties on page 53
|
|
SSLPEERNAME
SPEER
v Not set
v See SSL properties on page 53
STATREFRESHINT
SRI
v 60000
v Any positive integer
SUBSTORE
SS
v MIGRATE
v QUEUE
v BROKER
SYNCPOINTALLGETS SPAG
v No
v Yes
TARGCLIENT
TC
TEMPMODEL
TM
Any string
TOPIC
TOP
Any string
TRANSPORT
TRAN
USECONNPOOLING
UCP
v Yes
v No
Many of the properties are relevant only to a specific subset of the object types.
Table 12 on page 49 shows for each property which object types are valid, and
gives a brief description of each property. The object types are identified using
keywords; refer to Table 9 on page 44 for an explanation of these.
Numbers refer to notes at the end of the table. See also Property dependencies
on page 51. Appendix A, Mapping between Administration tool properties and
programmable properties on page 399 shows the relationship between properties
set by the tool and programmable properties.
48
QCF
TCF
BROKERCCDSUBQ
WSQCF
XAQCF
WSTCF
XATCF
Description
The name of the queue from which
durable subscription messages are
retrieved for a ConnectionConsumer
BROKERCCSUBQ
BROKERCONQ
BROKERDURSUBQ
BROKERPUBQ
BROKERQMGR
BROKERSUBQ
BROKERVER
Y4
CCSID
CHANNEL
Y
Y
CLEANUP
CLEANUPINT
CLIENTID
Y4
ENCODING
EXPIRY
DESCRIPTION
HOSTNAME3
Y4
MSGBATCHSZ
MSGRETENTION
PERSISTENCE
49
QCF
TCF
PRIORITY
POLLINGINT
PORT3
Y4
PUBACKINT
QMANAGER
WSQCF
XAQCF
QUEUE
Description
The priority for messages sent to a
destination
WSTCF
XATCF
RECEXIT
RECEXITINIT
SECEXIT
SECEXITINIT
SENDEXIT
SENDEXITINIT
|
|
SSLCIPHERSUITE
|
|
SSLCRL
|
|
|
SSLPEERNAME
STATREFRESHINT
SUBSTORE
SYNCPOINTALLGETS Y
TARGCLIENT2
TEMPMODEL
TOPIC
50
QCF
TCF
TRANSPORT3
USECONNPOOLING
WSQCF
XAQCF
WSTCF
XATCF
Description
Y4
Y1
Y1
Notes:
1. For WSTCF, WSQCF, XATCF, and XAQCF objects, only the BIND transport type is allowed.
2. The TARGCLIENT property indicates whether the WebSphere MQ RFH2 format is used to exchange information
with target applications.
The MQJMS_CLIENT_JMS_COMPLIANT constant indicates that the RFH2 format is used to send information.
Applications that use WebSphere MQ JMS understand the RFH2 format. You should set the
MQJMS_CLIENT_JMS_COMPLIANT constant when you exchange information with a target WebSphere MQ
JMS application.
The MQJMS_CLIENT_NONJMS_MQ constant indicates that the RFH2 format is not used to send information.
Typically, this value is used for an existing WebSphere MQ application (that is, one that does not handle RFH2).
3. HOSTNAME, PORT, and TRANSPORT are also used to identify if you are connecting to WebSphere MQ Event
Broker and the brokers IP hostname and listening port.
For more information about using WebSphere MQ Event Broker, see Chapter 11, Programming
publish/subscribe applications on page 203.
4. Only the BROKERVER, CLIENTID, DESCRIPTION, HOSTNAME, PORT, and TRANSPORT properties are
supported for a TopicConnectionFactory used with a direct connection across TCP/IP to WebSphere MQ Event
Broker.
Property dependencies
Some properties have dependencies on each other. This may mean that it is
meaningless to supply a property unless another property is set to a particular
value. The specific property groups where this can occur are
v Client properties
v Properties for connecting to WebSphere MQ Event Broker
v Exit initialization strings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Client properties
Some properties are only relevant to a connection with the TRANSPORT
property set to the value CLIENT. If this property is not explicitly set on a
connection factory to one of the values CLIENT or DIRECT, the transport
used on connections provided by the factory is WebSphere MQ Bindings.
Consequently, none of the client properties on this connection factory can
be configured. These are:
v HOST
v PORT
v CHANNEL
v CCSID
v
v
v
v
RECEXIT
RECEXITINIT
SECEXIT
SECEXITINIT
Chapter 5. Using the WebSphere MQ JMS administration tool
51
|
|
|
|
|
v
v
v
v
v
|
|
|
If you attempt to set any of these properties without setting the TRANSPORT
property to CLIENT (or, for some, DIRECT; see Properties for connecting
to WebSphere MQ Event Broker) , there will be an error.
Properties for connecting to WebSphere MQ Event Broker
The only properties used with a direct connection to WebSphere MQ Event
Broker are listed in note 4 associated with Table 12 on page 49.
The default values for PORT and BROKERVER are set by the definition of
TRANSPORT:
1. Defining a connection factory with TRANSPORT as CLIENT sets:
v BROKERVER to V1
v PORT to 1414
2. Defining a connection factory with TRANSPORT as DIRECT sets:
v BROKERVER to V2
v PORT to 1506
If you explicitly set the value of PORT or BROKERVER, a later change to the
value of TRANSPORT will not override your choices.
Exit initialization strings
You must not set any of the exit initialization strings unless the
corresponding exit name has been supplied. The exit initialization
properties are:
v RECEXITINIT
v SECEXITINIT
v SENDEXITINIT
For example, specifying RECEXITINIT(myString) without specifying
RECEXIT(some.exit.classname) causes an error.
decimal encoding
floating-point encoding
In this string:
v N denotes normal
v R denotes reversed
v 3 denotes z/OS
v the first character represents integer encoding
52
SSL properties
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The SSLPEERNAME matches the format of the SSLPEER parameter which can be
set on channel definitions. It is a list of attribute name and value pairs separated
by commas or semicolons. For example:
|
|
|
The set of names and values makes up a distinguished name. For more details about
distinguished names and their use with WebSphere MQ, see the WebSphere MQ
Security book.
|
|
|
|
|
The example given will cause the identifying certificate presented by the server to
be checked at connect-time. For the connection to succeed, the certificate must have
a Common Name beginning QMGR., and must have at least two Organizational
Unit names, the first of which must be IBM and the second WEBSPHERE.
Checking is case-insensitive.
|
|
|
|
|
|
The SSLCRL property specifies zero or more CRL (Certificate Revocation List)
servers. Use of this property requires a JVM at Java 2 v1.4. This is a
space-delimited list of entries of the form:
|
|
|
|
ldap://hostname:[port]
53
|
|
|
|
|
|
Unknown property
InitCtx/cn=Trash> DEFINE QCF(testQCF) PIZZA(ham and mushroom)
Unable to create a valid object, please check the parameters supplied
Unknown property: PIZZA
54
|
|
|
|
|
|
|
. . . 57
. . . 57
. . . 58
. . . 58
. . . 59
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
61
61
61
61
62
62
62
62
65
67
67
68
68
69
70
71
72
72
73
74
|
|
|
|
|
|
|
|
|
|
|
. 75
. 76
. 78
.
.
.
.
.
.
.
.
79
79
79
79
80
81
82
82
.
.
.
.
83
83
84
85
. 86
. 86
86
. 86
. . 89
. . 89
. . 90
. . 90
. . 90
MQPMRF_* values . . . . . . .
MQCNO_FASTPATH_BINDING . .
MQRO_* values . . . . . . . .
Miscellaneous differences with z/OS &
Features outside the core . . . . . .
MQQueueManager constructor option
MQQueueManager.begin() method .
MQGetMessageOptions fields . . .
Distribution lists. . . . . . . .
MQPutMessageOptions fields . . .
MQMD fields. . . . . . . . .
Chapter 9. The WebSphere MQ
classes and interfaces . . .
MQChannelDefinition . . . .
Variables . . . . . . .
Constructors . . . . . .
MQChannelExit . . . . . .
Variables . . . . . . .
Constructors. . . . . .
MQDistributionList . . . .
Constructors. . . . . .
Methods . . . . . . .
MQDistributionListItem . . .
Variables . . . . . . .
Constructors. . . . . .
MQEnvironment . . . . .
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQException . . . . . .
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQGetMessageOptions . . .
Variables . . . . . . .
Constructors. . . . . .
MQManagedObject . . . .
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQMessage . . . . . . .
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQMessageTracker . . . .
Variables . . . . . . .
MQPoolServices . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQPoolServicesEvent . . .
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQPoolToken . . . . . .
Constructors. . . . . .
base
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. . .
. . .
. . .
OS/390
. . .
. . .
. . .
. . .
. . .
. . .
. . .
Java
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. .
. 90
. 90
. 91
91
. 92
. 92
. 92
. 92
. 92
. 93
. 93
. 95
. 96
. 96
. 97
. 98
. 98
. 100
. 101
. 101
. 101
. 103
. 103
. 103
. 104
. 105
. 108
. 108
. 110
. 110
. 110
. 111
. 112
. 112
. 115
. 116
. 116
. 117
. 117
. 119
. 119
. 127
. 127
. 137
. 137
. 139
. 139
. 139
. 140
. 140
. 140
. 141
. 142
. 142
55
MQProcess . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQPutMessageOptions . . .
Variables . . . . . . .
Constructors. . . . . .
MQQueue . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQQueueManager . . . .
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQSimpleConnectionManager
Variables . . . . . . .
Constructors. . . . . .
Methods . . . . . . .
MQC . . . . . . . . .
MQPoolServicesEventListener .
Methods . . . . . . .
MQConnectionManager . . .
MQReceiveExit . . . . . .
Methods . . . . . . .
MQSecurityExit . . . . .
Methods . . . . . . .
MQSendExit. . . . . . .
Methods . . . . . . .
ManagedConnection . . . .
Methods . . . . . . .
ManagedConnectionFactory .
Methods . . . . . . .
ManagedConnectionMetaData .
Methods . . . . . . .
56
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
143
143
143
145
145
147
148
148
148
156
156
156
159
169
169
169
169
171
172
172
173
174
174
176
176
178
178
180
180
183
183
185
185
57
Advantages of Java
If you place your applet on a Web server that is accessible outside the corporate
firewall, anyone on the Internet can download and use your application. This
means that you can get messages into your WebSphere MQ system from anywhere
on the internet. This opens the door to building a whole new set of Internet
accessible service, support, and electronic commerce applications.
To compile Java applications on the iSeries & AS/400 platforms, you must first
install:
v The AS/400 Developer Kit for Java, 5769-JV1
v The Qshell Interpreter, OS/400 (5769-SS1) Option 30
58
59
60
Connection differences
The way you program for WebSphere MQ classes for Java has some dependencies
on the connection modes you want to use.
Client connections
When WebSphere MQ classes for Java is used as a client, it is similar to the
WebSphere MQ C client, but has the following differences:
v It supports only TCP/IP.
v It does not support connection tables.
v It does not read any WebSphere MQ environment variables at startup.
v Information that would be stored in a channel definition and in environment
variables is stored in a class called Environment. Alternatively, this information
can be passed as parameters when the connection is made.
v Error and exception conditions are written to a log specified in the MQException
class. The default error destination is the Java console.
Copyright IBM Corp. 1997, 2002
61
Connection differences
The WebSphere MQ classes for Java clients do not support the MQBEGIN verb or
fast bindings.
For general information on WebSphere MQ clients, see the WebSphere MQ Clients
book.
Bindings mode
The bindings mode of WebSphere MQ classes for Java differs from the client
modes in the following ways:
v Most of the parameters provided by the MQEnvironment class are ignored
v The bindings support the MQBEGIN verb and fast bindings into the WebSphere
MQ queue manager
Note: WebSphere MQ for iSeries and WebSphere MQ for z/OS do not support the
use of MQBEGIN to initiate global units of work that are coordinated by the
queue manager.
|
|
|
MQEnvironment.hostname
Set the value of this variable follows:
v For client connections, set this to the hostname of the WebSphere MQ
server to which you want to connect
v For bindings mode, set this to null
62
Example code
// ===========================================================================
//
// Licensed Materials - Property of IBM
//
// 5639-C34
//
// (c) Copyright IBM Corp. 1995,1999
//
// ===========================================================================
// WebSphere MQ Client for Java sample applet
//
// This sample runs as an applet using the appletviewer and HTML file,
// using the command ://
appletviewer MQSample.html
// Output is to the command line, NOT the applet viewer window.
//
// Note. If you receive WebSphere MQ error 2 reason 2059 and you are sure your
// WebSphere MQ and TCP/IP setup is correct,
// you should click on the "Applet" selection in the Applet viewer window
// select properties, and change "Network access" to unrestricted.
import com.ibm.mq.*;
// Include the WebSphere MQ classes for Java package
public class MQSample extends java.applet.Applet
{
private String hostname = "your_hostname";
private String channel
= "server_channel";
//
//
//
//
//
//
//
//
//
//
= channel;
63
Example code
public void start()
{
try {
// Create a connection to the queue manager
qMgr = new MQQueueManager(qManager);
// Set up the options on the queue we wish to open...
// Note. All WebSphere MQ Options are prefixed with MQC in Java.
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF |
MQC.MQOO_OUTPUT ;
// Now specify the queue that we wish to open, and the open options...
MQQueue system_default_local_queue =
qMgr.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE",
openOptions);
// Define a simple WebSphere MQ message, and write some text in UTF format..
MQMessage hello_world = new MQMessage();
hello_world.writeUTF("Hello World!");
// specify the message options...
MQPutMessageOptions pmo = new MQPutMessageOptions();
//
//
//
//
64
Example code
catch (MQException ex)
{
System.out.println("A WebSphere MQ error occurred : Completion code " +
ex.completionCode +
" Reason code " + ex.reasonCode);
}
// Was it a Java buffer space error?
catch (java.io.IOException ex)
{
System.out.println("An error occurred whilst writing to the
message buffer: " + ex);
}
} // end of start
} // end of sample
65
Example code
//
//
//
//
//
//
//
//
======================================================================
Licensed Materials - Property of IBM
5639-C34
(c) Copyright IBM Corp. 1995, 1999
======================================================================
WebSphere MQ classes for Java sample application
This sample runs as a Java application using the command :- java MQSample
import com.ibm.mq.*;
//
//
//
//
66
67
Channel name
Hostname
Port number
User ID
Password
To specify the channel name and hostname, use the following code:
MQEnvironment.hostname = "host.domain.com";
MQEnvironment.channel = "java.client.channel";
To disconnect from a queue manager, call the disconnect() method on the queue
manager:
queueManager.disconnect();
If you call the disconnect method, all open queues and processes that you have
accessed through that queue manager will be closed. However, it is good
programming practice to close these resources explicitly when you finish using
them. To do this, use the close() method.
The commit() and backout() methods on a queue manager replace the MQCMIT
and MQBACK calls that are used with the procedural interface.
The options parameter is the same as the Options parameter in the MQOPEN call.
The accessQueue method returns a new object of class MQQueue.
68
With WebSphere MQ classes for Java, you can also create a queue by using the
MQQueue constructor. The parameters are exactly the same as for the accessQueue
method, with the addition of a queue manager parameter. For example:
MQQueue queue = new MQQueue(queueManager,
"qName",
MQC.MQOO_OUTPUT,
"qMgrName",
"dynamicQName",
"altUserId");
Constructing a queue object in this way enables you to write your own subclasses
of MQQueue.
To access a process, use the accessProcess method in place of accessQueue. This
method does not have a dynamic queue name parameter, because this does not apply
to processes.
The accessProcess method returns a new object of class MQProcess.
When you have finished using the process object, use the close() method to close it,
as in the following example:
process.close();
With WebSphere MQ classes for Java, you can also create a process by using the
MQProcess constructor. The parameters are exactly the same as for the
accessProcess method, with the addition of a queue manager parameter.
Constructing a process object in this way enables you to write your own subclasses
of MQProcess.
Handling messages
You put messages onto queues using the put() method of the MQQueue class. You
get messages from queues using the get() method of the MQQueue class. Unlike
the procedural interface, where MQPUT and MQGET put and get arrays of bytes,
the Java programming language puts and gets instances of the MQMessage class.
The MQMessage class encapsulates the data buffer that contains the actual
message data, together with all the MQMD (message descriptor) parameters that
describe that message.
To build a new message, create a new instance of the MQMessage class, and use
the writeXXX methods to put data into the message buffer.
When the new message instance is created, all the MQMD parameters are
automatically set to their default values, as defined in the WebSphere MQ
Application Programming Reference. The put() method of MQQueue also takes an
instance of the MQPutMessageOptions class as a parameter. This class represents
the MQPMO structure. The following example creates a message and puts it onto a
queue:
// Build a new message containing my age followed by my name
MQMessage myMessage = new MQMessage();
myMessage.writeInt(25);
String name = "Wendy Ling";
Chapter 7. Writing WebSphere MQ base Java programs
69
Message handling
myMessage.writeInt(name.length());
myMessage.writeBytes(name);
// Use the default put message options...
MQPutMessageOptions pmo = new MQPutMessageOptions();
// put the message!
queue.put(myMessage,pmo);
You can alter the number format that the read and write methods use by setting
the encoding member variable.
You can alter the character set to use for reading and writing strings by setting the
characterSet member variable.
See MQMessage on page 119 for more details.
Note: The writeUTF() method of MQMessage automatically encodes the length of
the string as well as the Unicode bytes it contains. When your message will
be read by another Java program (using readUTF()), this is the simplest way
to send string information.
Handling errors
Methods in the Java interface do not return a completion code and reason code.
Instead, they throw an exception whenever the completion code and reason code
resulting from a WebSphere MQ call are not both zero. This simplifies the program
logic so that you do not have to check the return codes after each call to
WebSphere MQ. You can decide at which points in your program you want to deal
with the possibility of failure. At these points, you can surround your code with
try and catch blocks, as in the following example:
try {
myQueue.put(messageA,putMessageOptionsA);
myQueue.put(messageB,putMessageOptionsB);
}
catch (MQException ex) {
70
Error handling
// This block of code is only executed if one of
// the two put methods gave rise to a non-zero
// completion code or reason code.
System.out.println("An error occurred during the put operation:" +
"CC = " + ex.completionCode +
"RC = " + ex.reasonCode);
System.out.println("Cause exception:" + ex.getCause() );
|
}
The WebSphere MQ call reason codes reported back in Java exceptions are
documented in a chapter called Return Codes in the WebSphere MQ Application
Programming Reference book.
|
|
|
|
|
Sometimes the reason code does not convey all details associated with the error.
This can occur if WebSphere MQ uses services provided by another product (for
example, a JSSE implementation) which throws an Exception to WebSphere MQ. In
this case, the method MQException.getCause() will retrieve the underlying
Exception which caused the error.
71
Multithreaded programs
Multithreaded programs are hard to avoid in Java. Consider a simple program that
connects to a queue manager and opens a queue at startup. The program displays
a single button on the screen. When a user presses that button, the program fetches
a message from the queue.
The Java runtime environment is inherently multithreaded. Therefore, your
application initialization occurs in one thread, and the code that executes in
response to the button press executes in a separate thread (the user interface
thread).
With the C based WebSphere MQ client, this would cause a problem, because
handles cannot be shared across multiple threads. WebSphere MQ classes for Java
relaxes this constraint, allowing a queue manager object (and its associated queue
and process objects) to be shared across multiple threads.
The implementation of WebSphere MQ classes for Java ensures that, for a given
connection (MQQueueManager object instance), all access to the target WebSphere
MQ queue manager is synchronized. Therefore, a thread wishing to issue a call to
a queue manager is blocked until all other calls in progress for that connection are
complete. If you require simultaneous access to the same queue manager from
multiple threads within your program, create a new MQQueueManager object for
each thread that requires concurrent access. (This is equivalent to issuing a
separate MQCONN call for each thread.)
|
|
|
72
Connection pooling
WebSphere MQ classes for Java Version 5.2 provides additional support for
applications that deal with multiple connections to WebSphere MQ queue
managers. When a connection is no longer required, instead of destroying it, it can
be pooled, and later reused. This can provide a substantial performance
enhancement for applications and middleware that connect serially to arbitrary
queue managers.
WebSphere MQ provides a default connection pool. Applications can activate or
deactivate this connection pool by registering and deregistering tokens through the
MQEnvironment class. If the pool is active, when WebSphere MQ base Java
constructs an MQQueueManager object, it searches this default pool and reuses
any suitable connection. When an MQQueueManager.disconnect() call occurs, the
underlying connection is returned to the pool.
Chapter 7. Writing WebSphere MQ base Java programs
73
Connection pooling
Alternatively, applications can construct an MQSimpleConnectionManager
connection pool for a particular use. Then, the application can either specify that
pool during construction of an MQQueueManager object, or pass that pool to
MQEnvironment for use as the default connection pool.
Also, WebSphere MQ base Java provides a partial implementation of the Java 2
Platform Enterprise Edition (J2EE) Connector Architecture. Applications running
under a Java 2 v1.3 JVM with JAAS 1.0 (Java Authentication and Authorization
Service) can provide their own connection pool by implementing the
javax.resource.spi.ConnectionManager interface. Again, this interface can be
specified on the MQQueueManager constructor, or specified as the default
connection pool.
MQApp1 takes a list of local queue managers from the command line, connects to
each in turn, and performs some operation. However, when the command line lists
the same queue manager many times, it is more efficient to connect only once, and
to reuse that connection many times.
WebSphere MQ base Java provides a default connection pool that you can use to
do this. To enable the pool, use one of the
MQEnvironment.addConnectionPoolToken() methods. To disable the pool, use
MQEnvironment.removeConnectionPoolToken().
The following example application, MQApp2, is functionally identical to MQApp1,
but connects only once to each queue manager.
import com.ibm.mq.*;
public class MQApp2
{
public static void main(String[] args) throws MQException
{
MQPoolToken token=MQEnvironment.addConnectionPoolToken();
for (int i=0; i<args.length; i++) {
MQQueueManager qmgr=new MQQueueManager(args[i]);
:
: (do something with qmgr)
:
qmgr.disconnect();
}
74
Connection pooling
MQEnvironment.removeConnectionPoolToken(token);
}
}
The first bold line activates the default connection pool, by registering an
MQPoolToken object with MQEnvironment.
The MQQueueManager constructor now searches this pool for an appropriate
connection and only creates a connection to the queue manager if it cannot find an
existing one. The qmgr.disconnect() call returns the connection to the pool for later
reuse. These API calls are the same as the sample application MQApp1.
The second highlighted line deactivates the default connection pool, which
destroys any queue manager connections stored in the pool. This is important
because otherwise, the application would terminate with a number of live queue
manager connections in the pool. This situation could cause errors that would
appear in the queue manager logs.
The default connection pool stores a maximum of ten unused connections, and
keeps unused connections active for a maximum of five minutes. The application
can alter this (for details, see Supplying a different connection pool on page 76).
Instead of using MQEnvironment to supply an MQPoolToken, the application can
construct its own:
MQPoolToken token=new MQPoolToken();
MQEnvironment.addConnectionPoolToken(token);
75
Connection pooling
{
for (int i=0; i<10; i++) {
MQApp3_Thread thread=new MQApp3_Thread(i*60000);
thread.start();
}
}
}
class MQApp3_Thread extends Thread
{
long time;
public MQApp3_Thread(long time)
{
this.time=time;
}
public synchronized void run()
{
MQPoolToken token=MQEnvironment.addConnectionPoolToken();
try {
wait(time);
MQQueueManager qmgr=new MQQueueManager("my.qmgr.1");
:
: (do something with qmgr)
:
qmgr.disconnect();
}
catch (MQException mqe) {System.err.println("Error occurred!");}
catch (InterruptedException ie) {}
MQEnvironment.removeConnectionPoolToken(token);
}
}
76
Connection pooling
The connection that is forged during the first MQQueueManager constructor is
stored in myConnMan after the qmgr.disconnect() call. The connection is then
reused during the second call to the MQQueueManager constructor.
The second line enables the MQSimpleConnectionManager. The last line disables
MQSimpleConnectionManager, destroying any connections held in the pool. An
MQSimpleConnectionManager is, by default, in MODE_AUTO, which is described
later in this section.
An MQSimpleConnectionManager allocates connections on a most-recently-used
basis, and destroys connections on a least-recently-used basis. By default, a
connection is destroyed if it has not been used for five minutes, or if there are
more than ten unused connections in the pool. You can alter these values using:
v MQSimpleConnectionManager.setTimeout()
v MQSimpleConnectionManager.setHighThreshold()
It is also possible to set up an MQSimpleConnectionManager for use as the default
connection pool, to be used when no Connection Manager is supplied on the
MQQueueManager constructor.
The following application demonstrates this:
import com.ibm.mq.*;
public class MQApp4
{
public static void main(String[] args)
{
MQSimpleConnectionManager myConnMan=new MQSimpleConnectionManager();
myConnMan.setActive(MQSimpleConnectionManager.MODE_AUTO);
myConnMan.setTimeout(3600000);
myConnMan.setHighThreshold(50);
MQEnvironment.setDefaultConnectionManager(myConnMan);
MQApp3.main(args);
}
}
77
Connection pooling
78
Connection pooling
The ConnectionEventListener is notified if a severe error occurs on the connection,
or when MQQueueManager.disconnect() is called. When
MQQueueManager.disconnect() is called, the ConnectionEventListener can do
either of the following:
v reset the ManagedConnection using the mc.cleanup() call, then return the
ManagedConnection to the pool
v destroy the ManagedConnection using the mc.destroy() call
If the ConnectionManager is intended to be the default ConnectionManager, it can
also register an interest in the state of the MQEnvironment-managed set of
MQPoolTokens. To do so, first construct an MQPoolServices object, then register an
MQPoolServicesEventListener object with the MQPoolServices object:
MQPoolServices mqps=new MQPoolServices();
mqps.addMQPoolServicesEventListener(listener);
The listener is notified when an MQPoolToken is added or removed from the set,
or when the default ConnectionManager changes. The MQPoolServices object also
provides a way to query the current size of the set of MQPoolTokens.
Installation
In order to use the XA-JTA support, you will need to use a special JTA switch
library which is supplied. The method for using this library varies depending on
whether you are using Windows systems or one of the other platforms.
79
JTA/JDBC coordination
make db2
The Makefiles are set up to link against the databases and JDKs in their standard
installed location. The exception to this is Oracle, which can be installed anywhere
on the system and therefore the makefile makes use of Oracles ORACLE_HOME
environment variable to link the library correctly. If your JDK is in a non-standard
location, you can override the default directory with the JAVA_HOME definition:
make JAVA_HOME=/usr/my_jdk13 oracle
The above command should produce a switch file named jdbcora, which is used
in the same way as a standard switch library, including using the same
XAOpenString. Therefore, if you have previously configured an
XAResourceManager in your qm.ini you should replace the SwitchFile line with
a reference to the new JTA specific switch file. If you have not previously used an
XA switch file then refer to WebSphere MQ System Administration Guide for the
details of configuring the XAResourceManager stanza for different databases,
remembering to replace the standard switch file with the Java specific one.
Once the qm.ini has been updated, the queue manager will need to be restarted.
Ensure that all appropriate database environment variables have been set before
calling strmqm.
Usage
The basic sequence of API calls for a user application is:
qMgr = new MQQueueManager("QM1")
Connection con = qMgr.getJDBCConnection( xads );
qMgr.begin()
< Perform MQ and DB operations to be grouped in a unit of work >
qMgr.commit() or qMgr.backout();
con.close()
qMgr.disconnect()
80
JTA/JDBC coordination
the jta.jar file to be added to the classpath for programs which didnt previously
require it.
81
JTA/JDBC coordination
AMQ6174: The library C:\Program Files\IBM\MQSeries\Java\lib\jdbc\jdbcdb2.dll
was not found. The queue manager will continue without this module.
In fact, the file not found is jvm.dll. The solution is to either copy jvm.dll
to somewhere already on the path or update the path to include the
location of jvm.dll.
|
|
|
|
|
|
|
|
|
|
|
WebSphere MQ classes for Java uses Java Secure Socket Extension (JSSE) to handle
SSL encryption, and so requires a JSSE provider. J2SE v1.4 JVMs have a JSSE
provider built-in. Details of how to manage and store certificates can vary from
provider to provider. For information about this, refer to your JSSE providers
documentation.
|
|
This section assumes your JSSE provider is correctly installed and configured, and
suitable certificates have been installed and made available to your JSSE provider.
Enabling SSL
|
|
|
|
|
|
|
|
|
SSL is supported only for client connections. To enable SSL, you must specify the
CipherSuite to use when communicating with the queue manager, and this must
match the CipherSpec set on the target channel. Additionally, the named
CipherSuite must be supported by your JSSE provider. However, CipherSuites are
distinct from CipherSpecs and so have different names. Appendix H, SSL
CipherSuites supported by WebSphere MQ on page 425 contains a table mapping
the CipherSpecs supported by WebSphere MQ to their equivalent CipherSuites as
known to JSSE.
|
|
|
|
|
|
|
|
To enable SSL, specify the CipherSuite using the sslCipherSuite static member
variable of MQEnvironment. The following example attaches to a SVRCONN
channel named SECURE.SVRCONN.CHANNEL which has been set up to require
SSL with a CipherSpec of RC4_MD5_EXPORT:
|
|
|
|
|
Note that while the channel has a CipherSpec of RC4_MD5_EXPORT, the Java
application must specify a CipherSuite of SSL_RSA_EXPORT_WITH_RC4_40_MD5.
For more information about CipherSpecs and CipherSuites, see the WebSphere MQ
Security book. See Appendix H, SSL CipherSuites supported by WebSphere MQ
on page 425 for a list of mappings between CipherSpecs and CipherSuites.
|
|
|
|
|
To successfully connect using SSL, the JSSE TrustStore must be set up with
Certicate Authority root certificates from which the certificate presented by the
queue manager can be authenticated. Similarly, if SSLClientAuth on the SVRCONN
MQEnvironment.hostname
= "your_hostname";
MQEnvironment.channel
= "SECURE.SVRCONN.CHANNEL";
MQEnvironment.sslCipherSuite = "SSL_RSA_EXPORT_WITH_RC4_40_MD5";
MQQueueManager qmgr = new MQQueueManager("your_Q_manager");
82
SSL support
|
|
|
|
|
|
|
|
|
|
The queue manager identifies itself using an SSL certificate, which contains a
Distinguished Name (DN). A WebSphere MQ Java client application can use this DN
to ensure that it is communicating with the correct queue manager. A DN pattern
is specified using the sslPeerName variable of MQEnvironment. For example,
setting:
|
|
|
only allows the connection to succeed if the queue manager presents a certificate
with a Common Name beginning QMGR., and at least two Organizational Unit
names, the first of which must be IBM and the second WEBSPHERE.
|
|
|
|
|
|
|
|
|
|
|
|
|
A certificate revocation list (CRL) is a set of certificates that have been revoked,
either by the issuing Certificate Authority or by the local organization. CRLs are
typically hosted on LDAP servers. With Java 2 v1.4, a CRL server can be specified
at connect-time and the certificate presented by the queue manager will be checked
against the CRL before the connection is allowed. For more information about
certificate revocation lists and WebSphere MQ, see the WebSphere MQ Security
book.
|
|
|
|
Note: To use a CertStore successfully with a CRL hosted on an LDAP server, make
sure that your Java Software Development Kit (SDK) is compatible with the
CRL. Some SDKs require that the CRL conforms to RFC 2587 which defines
a schema for LDAP v2. Most LDAP v3 servers use RFC 2256 instead.
|
|
|
|
|
|
|
The CRLs to use are specified through the java.security.cert.CertStore class. Refer to
documentation on this class for full details of how to obtain instances of CertStore.
To create a CertStore based on an LDAP server, you should first create an
LDAPCertStoreParameters instance, initialized with the server and port settings to
use. For example:
|
|
|
|
|
|
|
|
Other CertStore types (for example, Collection) are also supported. Commonly
there are several CRL servers set up with identical CRL information to give
redundancy. Once you have a CertStore object for each of these CRL servers, you
should place them all in a suitable Collection. The following example shows the
CertStore objects placed in an ArrayList:
import java.security.cert.*;
CertStoreParameters csp = new LDAPCertStoreParameters("crl_server", 389);
83
SSL support
|
|
|
import java.util.ArrayList;
Collection crls = new ArrayList();
crls.add(cs);
|
|
|
This Collection can be set into the MQEnvironment static variable, sslCertStores,
before connecting to enable CRL checking:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The certificate presented by the queue manager when a connection is being set up
is validated as follows:
1. The first CertStore object in the Collection identified by sslCertStores is used to
identify a CRL server.
2. An attempt is made to contact the CRL server.
3. If the attempt is successful, the server is searched for a match for the certificate.
a. If the certificate is found to be revoked, the search process is over and the
connection request will fail with reason code
MQRC_SSL_CERTIFICATE_REVOKED.
The Collection object determines the order in which CertStores are used.
|
|
|
|
|
MQEnvironment.sslCertStores = crls;
b. If the certificate is not found, the search process is over and the connection
is allowed to proceed.
4. If the attempt to contact the server is unsuccessful, the next CertStore object is
used to identify a CRL server and the process repeats from An attempt is
made to contact the CRL server.
If this was the last CertStore in the Collection, or if the Collection contains no
CertStore objects, the search process has failed and the connection request will
fail with reason code MQRC_SSL_CERT_STORE_ERROR.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84
SSL support
|
|
javax.net.ssl.SSLSocketFactory sf = sslContext.getSocketFactory();
MQEnvironment.sslSocketFactory = sf;
|
|
|
|
|
WebSphere MQ classes for Java will then use this SSLSocketFactory to connect to
the WebSphere MQ queue manager. This property can also be set using the
MQC.SSL_SOCKET_FACTORY_PROPERTY. If sslSocketFactory is set to null, the
JVMs default SSLSocketFactory will be used. This property is ignored if
sslCipherSuite is not set.
|
|
The following reason codes may be issued by WebSphere MQ classes for Java
when connecting to a queue manager using SSL:
|
|
|
MQRC_SSL_NOT_ALLOWED
The sslCipherSuite property was set, but bindings connect was used. Only
client connect supports SSL.
|
|
|
|
|
|
MQRC_JSSE_ERROR
The JSSE provider reported an error which could not be handled by
WebSphere MQ. This could be caused by a configuration problem with
JSSE, or because the certificate presented by the queue manager could not
be validated. The exception produced by JSSE can be retrieved using the
getCause() method on MQException.
|
|
|
MQRC_SSL_PEER_NAME_MISMATCH
The DN pattern specified in the sslPeerName property did not match the
DN presented by the queue manager.
|
|
MQRC_SSL_PEER_NAME_ERROR
The DN pattern specified in the sslPeerName property was not valid.
|
|
|
|
|
|
|
|
MQRC_UNSUPPORTED_CIPHER_SUITE
The CipherSuite named in sslCipherSuite was not recognised by the JSSE
provider. A full list of CipherSuites supported by the JSSE provider can be
obtained by a program using the
SSLSocketFactory.getSupportedCipherSuites() method. A list of
CipherSuites which can be used to communicate with WebSphere MQ can
be found in Appendix H, SSL CipherSuites supported by WebSphere MQ
on page 425.
|
|
|
|
MQRC_SSL_CERTIFICATE_REVOKED
The certificate presented by the queue manager was found in a CRL
specified with the sslCertStores property. Update the queue manager to use
trusted certificates.
|
|
|
|
|
|
|
|
MQRC_SSL_CERT_STORE_ERROR
None of the supplied CertStores could be searched for the certificate
presented by the queue manager. The MQException.getCause() method
will return the error which occurred while searching the first CertStore
attempted. If the causal exception is NoSuchElementException,
ClassCastException or NullPointerException, check that the Collection
specified on the sslCertStores property contains at least one valid CertStore
object.
85
Run your applet either by loading this HTML file into a Java enabled Web browser,
or by using the appletviewer that comes with the Java Development Kit (JDK).
To use the applet viewer, enter the command:
appletviewer myclass.html
// trace at level 2
// these commands will be traced
// turn tracing off again
86
87
88
|
|
|
The WebSphere MQ classes for Java allow you to create applications that can run
against different versions of WebSphere MQ and MQSeries. This chapter describes
the behavior of the Java classes dependent on these different versions.
|
|
|
|
|
|
Except where noted here, the behavior exhibited will be as described in the
Application Programming Reference book appropriate to the queue manager.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Core details
WebSphere MQ classes for Java contains the following core set of classes, which
can be used in all environments with only the minor variations listed in
Restrictions and variations for core classes on page 90.
v MQEnvironment
v MQException
v MQGetMessageOptions
Excluding:
MatchOptions
GroupStatus
SegmentStatus
Segmentation
v MQManagedObject
Excluding:
inquire()
set()
v MQMessage
Excluding:
groupId
messageFlags
messageSequenceNumber
offset
originalLength
v MQPoolServices
v MQPoolServicesEvent
v MQPoolServicesEventListener
v MQPoolToken
v MQPutMessageOptions
Excluding:
knownDestCount
unknownDestCount
invalidDestCount
recordFields
v MQProcess
v MQQueue
v MQQueueManager
89
Core details
|
|
|
|
|
Excluding:
begin()
accessDistributionList()
v MQSimpleConnectionManager
v MQC
|
|
|
|
|
|
|
Notes:
1. Some constants are not included in the core (see Restrictions and variations for
core classes for details), and you should not use them in completely portable
programs.
2. Some platforms do not support all connection modes. On these platforms, you
can use only the core classes and options that relate to the supported modes.
(See Table 1 on page 5.)
|
|
|
|
|
|
MQGMO_* values
|
|
|
|
|
|
|
|
|
|
|
|
The following MQGMO_* values are not supported by all queue managers, and
their use may result in MQException being thrown from a MQQueue.get():
MQGMO_SYNCPOINT_IF_PERSISTENT
MQGMO_MARK_SKIP_BACKOUT
MQGMO_BROWSE_MSG_UNDER_CURSOR
MQGMO_LOCK
MQGMO_UNLOCK
MQGMO_LOGICAL_ORDER
MQGMO_COMPLETE_MESSAGE
MQGMO_ALL_MSGS_AVAILABLE
MQGMO_ALL_SEGMENTS_AVAILABLE
MQPMO_* values
The following MQPMO_* values are not supported by all queue managers, and
their use may result in MQException being thrown from a MQQueue.put() or a
MQQueueManager.put():
MQPMO_NEW_MESSAGE_ID
MQPMO_NEW_CORREL_ID
MQPMO_LOGICAL_ORDER
|
|
|
|
|
|
MQPMRF_* values
These are only used when putting messages to a distribution list, and so are only
supported by queue managers supporting distribution lists. For example, z/OS &
OS/390 queue managers do not support distribution lists.
|
|
|
MQCNO_FASTPATH_BINDING
This value is ignored on queue managers which do not support it, or when using a
TCP/IP client connection.
|
|
90
Restrictions
|
|
|
|
|
|
|
|
|
|
|
|
MQRO_* values
The following report options can be set but are ignored by some queue managers.
This can affect applications connected to a queue manager which does honor the
report options when the report message should be generated by a remote queue
manager that does not. Avoid relying on these options if there is a possibility that
a queue manager involved does not support them.
MQRO_EXCEPTION_WITH_FULL_DATA
MQRO_EXPIRATION_WITH_FULL_DATA
MQRO_COA_WITH_FULL_DATA
MQRO_COD_WITH_FULL_DATA
MQRO_DISCARD_MSG
|
|
|
|
|
|
Message priority
When a message is put with a priority greater than MaxPriority, a z/OS &
OS/390 queue manager will reject the put with MQCC_FAILED and
MQRC_PRIORITY_ERROR. Other platforms complete the put with
MQCC_WARNING and MQRC_PRIORITY_EXCEEDS_MAXIMUM, and
treat the message as if it were put with MaxPriority.
|
|
|
BackoutCount
A z/OS & OS/390 queue manager will return a maximum BackoutCount
of 255, even if the message has been backed out more than 255 times.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MQQueueManager constructor
Client connect is not supported on z/OS & OS/390. Attempting to connect
with client options will result in an MQException with MQCC_FAILED
and MQRC_ENVIRONMENT_ERROR. The MQQueueManager constructor
may also fail with MQRC_CHAR_CONVERSION_ERROR if it fails to
initialize conversion between the IBM-1047 and ISO8859-1 code pages, or
MQRC_UCS2_CONVERSION_ERROR if it fails to initialize conversion
between the queue managers code page and Unicode. If your application
fails with one of these reason codes, ensure that the National Language
Resources component of Language Environment is installed, and ensure
that the correct conversion tables are available.
|
|
|
Conversion tables for Unicode are installed as part of the OS/390 C/C++
optional feature. See the OS/390: C/C++ Programming Guide (SC09-2362) for
more information about enabling UCS-2 conversions.
91
|
|
|
|
|
|
|
|
|
|
|
|
|
MQQueueManager.begin() method
This can only be used against a WebSphere MQ V5.3 queue manager on UNIX or
Windows systems in bindings mode. Otherwise, it will fail with
MQRC_ENVIRONMENT_ERROR. See JTA/JDBC coordination via WebSphere
MQ base Java on page 79 for more details.
|
|
|
|
MQGetMessageOptions fields
|
|
|
|
|
|
When using a queue manager which does not support the Version 2 MQGMO
structure, you must leave the following fields set to their default values:
GroupStatus
SegmentStatus
Segmentation
|
|
|
|
|
Distribution lists
|
|
|
|
|
|
|
|
|
|
92
MQPutMessageOptions fields
|
|
|
|
|
|
Four fields in the MQPMO are rendered as the following member variables in the
MQPutMessageOptions class:
knownDestCount
unknownDestCount
invalidDestCount
recordFields
|
|
|
|
|
These fields are primarily intended for use with distribution lists. However, a
queue manager which supports distribution lists will also fill in the DestCount
fields after an MQPUT to a single queue. For example, if the queue resolves to a
local queue, knownDestCount is set to 1 and the other two count fields are set to
0.
|
|
|
|
If the queue manager does not support distribution lists, these values are
simulated as follows:
v If the put() succeeds, unknownDestCount is set to 1, and the others are set to 0.
v If the put() fails, invalidDestCount is set to 1, and the others are set to 0.
|
|
|
|
The recordFields variable is used with distribution lists. A value may be written
into recordFields at any time, regardless of the environment. It is ignored if the
MQPutMessageOptions object is used on a subsequent MQQueue.put() or
MQQueueManager.put(), rather than MQDistributionList.put().
MQMD fields
|
|
|
|
|
|
The following MQMD fields are largely concerned with message segmentation:
GroupId
MsgSeqNumber
Offset
MsgFlags
OriginalLength
|
|
|
|
|
|
|
If an application sets any of these MQMD fields to values other than their defaults,
and then does a put() or get() on a queue manager which does not support these,
the put() or get() will raise an MQException with MQRC_MD_ERROR. A
successful put() or get() with such a queue manager will always leave the MQMD
fields set to their default values. A grouped or segmented message should not
normally be sent to a Java application that runs against a queue manager that does
not support message grouping and segmentation.
|
|
|
|
|
|
|
If a Java application attempts to get() a message from a queue manager which does
not support these fields, and the physical message to be retrieved is part of a
group of segmented message (that is, it has non-default values for the MQMD
fields), it is retrieved without error. However, the MQMD fields in the MQMessage
are not updated, the MQMessage format property is set to
MQFMT_MD_EXTENSION, and the true message data is prefixed with an
MQMDE structure that contains the values for the new fields.
93
94
95
MQChannelDefinition
MQChannelDefinition
java.lang.Object
com.ibm.mq.MQChannelDefinition
Variables
channelName
public String channelName
The name of the channel through which the connection is established.
connectionName
public String connectionName
The TCP/IP hostname of the machine on which the queue manager
resides.
maxMessageLength
public int maxMessageLength
The maximum length of message that can be sent to the queue manager.
queueManagerName
public String queueManagerName
The name of the queue manager to which the connection is made.
receiveUserData
public String receiveUserData
A storage area for the receive exit to use. Information placed here is
preserved across invocations of the receive exit, and is also available to the
send and security exits.
remotePassword
public String remotePassword
The password used to establish the connection.
remoteUserId
public String remoteUserId
The user id used to establish the connection.
securityUserData
public String securityUserData
A storage area for the security exit to use. Information placed here is
preserved across invocations of the security exit, and is also available to
the send and receive exits.
sendUserData
public String sendUserData
96
MQChannelDefinition
A storage area for the send exit to use. Information placed here is
preserved across invocations of the send exit, and is also available to the
security and receive exits.
|
|
|
|
|
sslPeerName
public String sslPeerName
If SSL is used to encrypt data on the wire, this is set to the Distinguished
Name presented by the queue manager during connection. If SSL is not
used, it is left at null.
Constructors
MQChannelDefinition
public MQChannelDefinition()
97
MQChannelExit
MQChannelExit
java.lang.Object
com.ibm.mq.MQChannelExit
Variables
MQXCC_CLOSE_CHANNEL
public final static int MQXCC_CLOSE_CHANNEL
MQXCC_OK
public final static int MQXCC_OK
MQXCC_SUPPRESS_FUNCTION
public final static int MQXCC_SUPPRESS_FUNCTION
MQXCC_SEND_AND_REQUEST_SEC_MSG
public final static int MQXCC_SEND_AND_REQUEST_SEC_MSG
MQXCC_SEND_SEC_MSG
public final static int MQXCC_SEND_SEC_MSG
MQXCC_SUPPRESS_EXIT
public final static int MQXCC_SUPPRESS_EXIT
MQXR_INIT
public final static int MQXR_INIT
MQXR_INIT_SEC
public final static int MQXR_INIT_SEC
MQXR_SEC_MSG
public final static int MQXR_SEC_MSG
MQXR_TERM
public final static int MQXR_TERM
MQXR_XMIT
public final static int MQXR_XMIT
MQXT_CHANNEL_SEC_EXIT
public final static int MQXT_CHANNEL_SEC_EXIT
MQXT_CHANNEL_SEND_EXIT
public final static int MQXT_CHANNEL_SEND_EXIT
MQXT_CHANNEL_RCV_EXIT
public final static int MQXT_CHANNEL_RCV_EXIT
capabilityFlags
public static final int capabilityFlags
98
MQChannelExit
Indicates the capability of the queue manager.
Only the MQC.MQCF_DIST_LISTS flag is supported.
exitID public int exitID
The type of exit that has been invoked. For an MQSecurityExit this is
always MQXT_CHANNEL_SEC_EXIT. For an MQSendExit this is always
MQXT_CHANNEL_SEND_EXIT, and for an MQReceiveExit this is always
MQXT_CHANNEL_RCV_EXIT.
exitReason
public int exitReason
The reason for invoking the exit. Possible values are:
MQXR_INIT
Exit initialization; called after the channel connection conditions
have been negotiated, but before any security flows have been
sent.
MQXR_INIT_SEC
Indicates that the exit is to initiate the security dialog with the
queue manager.
MQXR_SEC_MSG
Indicates to the security exit that a security message has been
received from the queue manager.
MQXR_TERM
Exit termination; called after the disconnect flows have been sent
but before the socket connection is destroyed.
MQXR_XMIT
For a send exit, indicates that data is to be transmitted to the
queue manager.
For a receive exit, indicates that data has been received from the
queue manager.
exitResponse
public int exitResponse
Set by the exit to indicate the action that WebSphere MQ classes for Java
should take next. Valid values are:
MQXCC_CLOSE_CHANNEL
Set by any exit to indicate that the connection to the queue
manager should be closed.
MQXCC_OK
Set by the security exit to indicate that security exchanges are
complete.
Set by send exit to indicate that the returned data is to be
transmitted to the queue manager.
Set by the receive exit to indicate that the returned data is available
for processing by the WebSphere MQ Client for Java.
MQXCC_SEND_AND_REQUEST_SEC_MSG
Set by the security exit to indicate that the returned data is to be
transmitted to the queue manager, and that a response is expected
from the queue manager.
99
MQChannelExit
MQXCC_SEND_SEC_MSG
Set by the security exit to indicate that the returned data is to be
transmitted to the queue manager, and that no response is
expected.
MQXCC_SUPPRESS_EXIT
Set by any exit to indicate that it should no longer be called.
MQXCC_SUPPRESS_FUNCTION
Set by the security exit to indicate that communications with the
queue manager should be shut down.
exitUserArea
public byte exitUserArea[]
A storage area available for the exit to use.
Any data placed in the exitUserArea is preserved by the WebSphere MQ
Client for Java across exit invocations with the same exitID. (That is, the
send, receive, and security exits each have their own, independent, user
areas.)
fapLevel
public static final int fapLevel
The negotiated Format and Protocol (FAP) level.
maxSegmentLength
public int maxSegmentLength
The maximum length for any one transmission to a queue manager.
If the exit returns data that is to be sent to the queue manager, the length
of the returned data should not exceed this value.
Constructors
MQChannelExit
public MQChannelExit()
100
MQDistributionList
MQDistributionList
java.lang.Object
com.ibm.mq.MQManagedObject
com.ibm.mq.MQDistributionList
Constructors
MQDistributionList
public MQDistributionList(MQQueueManager qMgr,
MQDistributionListItem[] litems,
int openOptions,
String alternateUserId)
throws MQException
Methods
getFirstDistributionListItem
public MQDistributionListItem getFirstDistributionListItem()
Returns the first item in the distribution list, or null if the list is empty.
getInvalidDestinationCount
public int getInvalidDestinationCount()
Returns the number of items in the distribution list that failed to open
successfully.
getValidDestinationCount
public int getValidDestinationCount()
Returns the number of items in the distribution list that were opened
successfully.
put
public synchronized void put(MQMessage message,
MQPutMessageOptions putMessageOptions )
throws MQException
Chapter 9. The WebSphere MQ base Java classes and interfaces
101
MQDistributionList
Puts a message to the queues on the distribution list.
Parameters
message
An input/output parameter containing the message descriptor
information and the returned message data.
putMessageOptions
Options that control the action of MQPUT. (See
MQPutMessageOptions on page 145 for details.)
Throws MQException if the put fails.
102
MQDistributionListItem
MQDistributionListItem
java.lang.Object
com.ibm.mq.MQMessageTracker
com.ibm.mq.MQDistributionListItem
Variables
completionCode
public int completionCode
The completion code resulting from the last operation on this item. If this
was the construction of an MQDistributionList, the completion code relates
to the opening of the queue. If it was a put operation, the completion code
relates to the attempt to put a message onto this queue.
The initial value is 0.
queueManagerName
public String queueManagerName
The name of the queue manager on which the queue is defined.
The initial value is .
queueName
public String queueName
The name of a queue you want to use with a distribution list. This cannot
be the name of a model queue.
The initial value is .
reasonCode
public int reasonCode
The reason code resulting from the last operation on this item. If this was
the construction of an MQDistributionList, the reason code relates to the
opening of the queue. If it was a put operation, the reason code relates to
the attempt to put a message onto this queue.
The initial value is 0.
Constructors
MQDistributionListItem
public MQDistributionListItem()
Construct a new MQDistributionListItem object.
103
MQEnvironment
MQEnvironment
java.lang.Object
com.ibm.mq.MQEnvironment
Variables
Note: Variables marked with * do not apply when connecting directly to
WebSphere MQ in bindings mode.
CCSID*
public static int CCSID
The CCSID used by the client.
Changing this value affects the way that the queue manager you connect
to translates information in the WebSphere MQ headers. All data in
WebSphere MQ headers is drawn from the invariant part of the ASCII
codeset, except for the data in the applicationIdData and the
putApplicationName fields of the MQMessage class. (See MQMessage on
page 119.)
If you avoid using characters from the variant part of the ASCII codeset for
these two fields, you are then safe to change the CCSID from 819 to any
other ASCII codeset.
If you change the clients CCSID to be the same as that of the queue
manager to which you are connecting, you gain a performance benefit at
the queue manager because it does not attempt to translate the message
headers.
The default value is 819.
channel*
public static String channel
The name of the channel to connect to on the target queue manager. You
must set this member variable, or the corresponding property, before
constructing an MQQueueManager instance for use in client mode.
104
MQEnvironment
hostname*
public static String hostname
The TCP/IP hostname of the machine on which the WebSphere MQ server
resides. If the hostname is not set, and no overriding properties are set,
bindings mode is used to connect to the local queue manager.
password*
public static String password
Equivalent to the WebSphere MQ environment variable MQ_PASSWORD.
If a security exit is not defined for this client, the value of password is
transmitted to the server and is available to the server security exit when it
is invoked. The value may be used to verify the identity of the WebSphere
MQ client.
The default value is .
port*
properties
public static java.util.Hashtable properties
A set of key/value pairs defining the WebSphere MQ environment.
This hash table allows you to set environment properties as key/value
pairs rather than as individual variables.
The properties can also be passed as a hash table in a parameter on the
MQQueueManager constructor. Properties passed on the constructor take
precedence over values set with this properties variable, but they are
otherwise interchangeable. The order of precedence of finding properties is:
1. properties parameter on MQQueueManager constructor
2. MQEnvironment.properties
3. Other MQEnvironment variables
4. Constant default values
The possible Key/value pairs are shown in the following table:
Key
Value
MQC.CCSID_PROPERTY
MQC.CHANNEL_PROPERTY
MQC.CONNECT_OPTIONS_PROPERTY
MQC.HOST_NAME_PROPERTY
MQC.ORB_PROPERTY
org.omg.CORBA.ORB (optional)
MQC.PASSWORD_PROPERTY
MQC.PORT_PROPERTY
MQC.RECEIVE_EXIT_PROPERTY
MQReceiveExit (overrides
MQEnvironment.receiveExit)
MQC.SECURITY_EXIT_PROPERTY
MQSecurityExit (overrides
MQEnvironment.securityExit)
MQC.SEND_EXIT_PROPERTY
MQSendExit (overrides
MQEnvironment.sendExit)
105
MQEnvironment
Key
Value
|
|
|
MQC.SSL_CERT_STORE_PROPERTY
java.util.Collection, or
java.security.cert.CertStore (overrides
MQEnvironment.sslCertStores)
|
|
MQC.SSL_CIPHER_SUITE_PROPERTY
String (overrides
MQEnvironment.sslCipherSuite)
|
|
MQC.SSL_PEER_NAME_PROPERTY
String (overrides
MQEnvironment.sslPeerName)
|
|
MQC.SSL_SOCKET_FACTORY_PROPERTY
javax.net.ssl.SSLSocketFactory (overrides
MQEnvironment.sslSocketFactory)
MQC.TRANSPORT_PROPERTY
MQC.TRANSPORT_MQSERIES_BINDINGS
or
MQC.TRANSPORT_MQSERIES_CLIENT
or
MQC.TRANSPORT_MQSERIES (the default,
which selects bindings or client, based on
the value of hostname.)
MQC.USER_ID_PROPERTY
receiveExit*
public static MQReceiveExit receiveExit
A receive exit allows you to examine, and possibly alter, data received
from a queue manager. It is normally used in conjunction with a
corresponding send exit at the queue manager.
To provide your own receive exit, define a class that implements the
MQReceiveExit interface, and assign receiveExit to an instance of that class.
Otherwise, you can leave receiveExit set to null, in which case no receive
exit will be called.
See also MQReceiveExit on page 174.
securityExit*
public static MQSecurityExit securityExit
A security exit allows you to customize the security flows that occur when
an attempt is made to connect to a queue manager.
To provide your own security exit, define a class that implements the
MQSecurityExit interface, and assign securityExit to an instance of that
class. Otherwise, you can leave securityExit set to null, in which case no
security exit will be called.
See also MQSecurityExit on page 176.
sendExit*
public static MQSendExit sendExit
A send exit allows you to examine, and possibly alter, the data sent to a
queue manager. It is normally used in conjunction with a corresponding
receive exit at the queue manager.
To provide your own send exit, define a class that implements the
MQSendExit interface, and assign sendExit to an instance of that class.
Otherwise, you can leave sendExit set to null, in which case no send exit
will be called.
See also MQSendExit on page 178.
106
MQEnvironment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sslCertStores*
public static java.util.Collection sslCertStores
A Collection of CertStore objects used for certificate revocation checking.
Use of this variable requires a JVM at Java 2 v1.4 or later. If sslCipherSuite
is set, this variable can be used to ensure that the queue managers
certificate has not become revoked. Each CertStore in the Collection
represents an identical copy of the certificate revocation list (CRL). For
more information on the behaviour of sslCertStores, refer to Using
certificate revocation lists on page 83. If set to null (default), the certificate
presented by the queue manager is not checked against any certificate
revocation list. This variable is ignored if sslCipherSuite is null.
sslCipherSuite*
public static String sslCipherSuite
If set, SSL is enabled for the connection. The sslCipherSuite should be set
to the CipherSuite name matching the CipherSpec set on the SVRCONN
channel. If set to null (default), no SSL encryption is performed.
sslPeerName*
public static String sslPeerName
A distinguished name pattern. If sslCipherSuite is set, this variable can be
used to ensure the correct queue manager is used. For a description of the
format for this value, see Using the distinguished name of the queue
manager on page 83. If set to null (default), no checking of the queue
managers DN is performed. This variable is ignored if sslCipherSuite is
null.
sslSocketFactory*
public static javax.net.ssl.SSLSocketFactory sslSocketFactory
The factory to use when connecting with SSL encryption. If sslCipherSuite
is set, this variable can be used to customize all aspects of the SSL
connection. For more information on constructing and customizing
SSLSocketFactory instances, refer to your JSSE provider; for information
regarding the use of this variable, refer to Supplying a customized
SSLSocketFactory on page 84. If set to null (default) and SSL encryption is
requested, the default SSLSocketFactory is used. This variable is ignored if
sslCipherSuite is null.
userID*
public static String userID
Equivalent to the WebSphere MQ environment variable MQ_USER_ID.
If a security exit is not defined for this client, the value of userID is
transmitted to the server and will be available to the server security exit
when it is invoked. The value may be used to verify the identity of the
WebSphere MQ client.
The default value is .
version_notice
public final static String version_notice
The current version of WebSphere MQ classes for Java.
107
MQEnvironment
Constructors
MQEnvironment
public MQEnvironment()
Methods
addConnectionPoolToken
public static void addConnectionPoolToken(MQPoolToken token)
addConnectionPoolToken
public static MQPoolToken addConnectionPoolToken()
enableTracing
public static void enableTracing(int level,
OutputStream stream)
108
MQEnvironment
getVersionNotice()
public static final String getVersionNotice()
setDefaultConnectionManager
public static void setDefaultConnectionManager(
MQConnectionManager cxManager)
109
MQException
MQException
java.lang.Object
java.lang.Throwable
java.lang.Exception
com.ibm.mq.MQException
Variables
completionCode
public int completionCode
WebSphere MQ completion code giving rise to the error. The possible
values are:
v MQException.MQCC_WARNING
v MQException.MQCC_FAILED
exceptionSource
public Object exceptionSource
The object instance that threw the exception. You can use this as part of
your diagnostics when determining the cause of an error.
log
reasonCode
public int reasonCode
WebSphere MQ reason code describing the error. For a full explanation of
the reason codes, refer to the WebSphere MQ Application Programming
Reference.
Constructors
MQException
public MQException(int completionCode,
int reasonCode,
Object source)
110
MQException
completionCode
The WebSphere MQ completion code.
reasonCode
The WebSphere MQ reason code.
source
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Methods
getCause
public Throwable getCause()
111
MQGetMessageOptions
MQGetMessageOptions
java.lang.Object
com.ibm.mq.MQGetMessageOptions
Variables
groupStatus*
public char groupStatus
This is an output field which indicates whether the retrieved message is in
a group, and if it is, whether it is the last in the group. Possible values are:
MQC.MQGS_LAST_MSG_IN_GROUP
Message is the last in the group. This is also the value returned if
the group consists of only one message.
MQC.MQGS_MSG_IN_GROUP
Message is in a group, but is not the last in the group.
MQC.MQGS_NOT_IN_GROUP
Message is not in a group.
matchOptions*
public int matchOptions
Selection criteria that determine which message is retrieved. The following
match options can be set:
MQC.MQMO_MATCH_CORREL_ID
Correlation id to be matched.
MQC.MQMO_MATCH_GROUP_ID
Group id to be matched.
MQC.MQMO_MATCH_MSG_ID
Message id to be matched.
MQC.MQMO_MATCH_MSG_SEQ_NUMBER
Match message sequence number.
MQC.MQMO_NONE
No matching required.
options
public int options
Options that control the action of MQQueue.get. Any or none of the
following values can be specified. If more than one option is required, the
values can be added together or combined using the bitwise OR operator.
MQC.MQGMO_ACCEPT_TRUNCATED_MSG
Allow truncation of message data.
112
MQGetMessageOptions
MQC.MQGMO_BROWSE_FIRST
Browse from start of queue.
MQC.MQGMO_BROWSE_MSG_UNDER_CURSOR*
Browse message under browse cursor.
MQC.MQGMO_BROWSE_NEXT
Browse from the current position in the queue.
MQC.MQGMO_CONVERT
Request the application data to be converted, to conform to the
characterSet and encoding attributes of the MQMessage, before the
data is copied into the message buffer. Because data conversion is
also applied as the data is retrieved from the message buffer,
applications do not usually set this option.
Using this option may cause problems when converting from
single byte character sets to double byte character sets. Instead, do
the conversion using the readString, readLine and writeString
methods after the message has been delivered.
MQC.MQGMO_FAIL_IF_QUIESCING
Fail if the queue manager is quiescing.
MQC.MQGMO_LOCK*
Lock the message that is browsed.
MQC.MQGMO_MARK_SKIP_BACKOUT*
Allow a unit of work to be backed out without reinstating the
message on the queue.
MQC.MQGMO_MSG_UNDER_CURSOR
Get message under browse cursor.
MQC.MQGMO_NONE
MQC.MQGMO_NO_SYNCPOINT
Get message without syncpoint control.
MQC.MQGMO_NO_WAIT
Return immediately if there is no suitable message.
MQC.MQGMO_SYNCPOINT
Get the message under syncpoint control; the message is marked
as being unavailable to other applications, but it is deleted from
the queue only when the unit of work is committed. The message
is made available again if the unit of work is backed out.
MQC.MQGMO_SYNCPOINT_IF_PERSISTENT*
Get message with syncpoint control if message is persistent.
MQC.MQGMO_UNLOCK*
Unlock a previously locked message.
MQC.MQGMO_WAIT
Wait for a message to arrive.
Segmenting and grouping WebSphere MQ messages can be sent or
received as a single entity, can be split into several segments for sending
and receiving, and can also be linked to other messages in a group.
Each piece of data that is sent is known as a physical message, which can
be a complete logical message, or a segment of a longer logical message.
Chapter 9. The WebSphere MQ base Java classes and interfaces
113
MQGetMessageOptions
Each physical message usually has a different MsgId. All the segments of a
single logical message have the same groupId value and MsgSeqNumber
value, but the Offset value is different for each segment. The Offset field
gives the offset of the data in the physical message from the start of the
logical message. The segments usually have different MsgId values, because
they are individual physical messages.
Logical messages that form part of a group have the same groupId value,
but each message in the group has a different MsgSeqNumber value.
Messages in a group can also be segmented.
The following options can be used for dealing with segmented or grouped
messages:
MQC.MQGMO_ALL_MSGS_AVAILABLE*
Retrieve messages from a group only when all the messages in the
group are available.
MQC.MQGMO_ALL_SEGMENTS_AVAILABLE*
Retrieve the segments of a logical message only when all the
segments in the group are available.
MQC.MQGMO_COMPLETE_MSG*
Retrieve only complete logical messages.
MQC.MQGMO_LOGICAL_ORDER*
Return messages in groups, and segments of logical messages, in
logical order.
resolvedQueueName
public String resolvedQueueName
This is an output field that the queue manager sets to the local name of the
queue from which the message was retrieved. This will be different from
the name used to open the queue if an alias queue or model queue was
opened.
segmentation*
public char segmentation
This is an output field that indicates whether or not segmentation is
allowed for the retrieved message is a segment of a logical message.
Possible values are:
MQC.MQSEG_INHIBITED
Segmentation not allowed.
MQC.MQSEG_ALLOWED
Segmentation allowed.
segmentStatus*
public char segmentStatus
This is an output field that indicates whether the retrieved message is a
segment of a logical message. If the message is a segment, the flag
indicates whether or not it is the last segment. Possible values are:
MQC.MQSS_LAST_SEGMENT
Message is the last segment of the logical message. This is also the
value returned if the logical message consists of only one segment.
MQC.MQSS_NOT_A_SEGMENT
Message is not a segment.
114
MQGetMessageOptions
MQC.MQSS_SEGMENT
Message is a segment, but is not the last segment of the logical
message.
waitInterval
public int waitInterval
The maximum time (in milliseconds) that an MQQueue.get call waits for a
suitable message to arrive (used in conjunction with
MQC.MQGMO_WAIT). A value of MQC.MQWI_UNLIMITED indicates
that an unlimited wait is required.
Constructors
MQGetMessageOptions
public MQGetMessageOptions()
Construct a new MQGetMessageOptions object with options set to
MQC.MQGMO_NO_WAIT, a wait interval of zero, and a blank resolved
queue name.
115
MQManagedObject
MQManagedObject
java.lang.Object
com.ibm.mq.MQManagedObject
Variables
alternateUserId
public String alternateUserId
The alternate user id (if any) specified when this resource was opened.
Setting this attribute has no effect.
closeOptions
public int closeOptions
Set this attribute to control the way the resource is closed. The default
value is MQC.MQCO_NONE, and this is the only permissible value for all
resources other than permanent dynamic queues, and temporary dynamic
queues that are being accessed by the objects that created them. For these
queues, the following additional values are permissible:
MQC.MQCO_DELETE
Delete the queue if there are no messages.
MQC.MQCO_DELETE_PURGE
Delete the queue, purging any messages on it.
connectionReference
public MQQueueManager connectionReference
The queue manager to which this resource belongs. Setting this attribute
has no effect.
isOpen
public boolean isOpen
Indicates whether this resource is currently open. This attribute is
deprecated and setting it has no effect.
name
openOptions
public int openOptions
The options specified when this resource was opened. Setting this attribute
has no effect.
116
MQManagedObject
Constructors
MQManagedObject
protected MQManagedObject()
Constructor method.
Methods
close
public synchronized void close()
throws MQException.
Close the object. No further operations against this resource are permitted
after this method has been called. The behavior of the close method may
be altered by setting the closeOptions attribute.
Throws MQException if the WebSphere MQ call fails.
getDescription
public String getDescription()
Throws MQException.
Return the description of this resource as held at the queue manager.
If this method is called after the resource has been closed, an MQException
is thrown.
inquire
public void inquire(int selectors[],
int intAttrs[],
byte charAttrs[])
throws MQException.
Returns an array of integers and a set of character strings containing the
attributes of an object (queue, process or queue manager).
The attributes to be queried are specified in the selectors array. Refer to the
WebSphere MQ Application Programming Reference for details of the
permissible selectors and their corresponding integer values.
Note that many of the more common attributes can be queried using the
getXXX() methods defined in MQManagedObject, MQQueue,
MQQueueManager, and MQProcess.
Parameters
selectors
Integer array identifying the attributes with values to be inquired
on.
intAttrs
The array in which the integer attribute values are returned.
Integer attribute values are returned in the same order as the
integer attribute selectors in the selectors array.
Chapter 9. The WebSphere MQ base Java classes and interfaces
117
MQManagedObject
charAttrs
The buffer in which the character attributes are returned,
concatenated. Character attributes are returned in the same order
as the character attribute selectors in the selectors array. The length
of each attribute string is fixed for each attribute.
Throws MQException if the inquire fails.
isOpen
public boolean isOpen()
Returns the value of the isOpen variable.
set
public synchronized void set(int selectors[],
int intAttrs[],
byte charAttrs[])
throws MQException.
Set the attributes defined in the selectors vector.
The attributes to be set are specified in the selectors array. Refer to the
WebSphere MQ Application Programming Reference for details of the
permissible selectors and their corresponding integer values.
Note that some queue attributes can be set using the setXXX() methods
defined in MQQueue.
Parameters
selectors
Integer array identifying the attributes with values to be set.
intAttrs
The array of integer attribute values to be set. These values must
be in the same order as the integer attribute selectors in the
selectors array.
charAttrs
The buffer in which the character attributes to be set are
concatenated. These values must be in the same order as the
character attribute selectors in the selectors array. The length of
each character attribute is fixed.
Throws MQException if the set fails.
118
MQMessage
MQMessage
java.lang.Object
com.ibm.mq.MQMessage
Variables
accountingToken
public byte accountingToken[]
Part of the identity context of the message; it allows an application to
cause work done as a result of the message to be appropriately charged.
The default value is MQC.MQACT_NONE.
applicationIdData
public String applicationIdData
Part of the identity context of the message; it is information that is defined
by the application suite, and can be used to provide additional information
about the message or its originator.
The default value is .
applicationOriginData
public String applicationOriginData
Information defined by the application that can be used to provide
additional information about the origin of the message.
The default value is .
backoutCount
public int backoutCount
A count of the number of times the message has previously been returned
by an MQQueue.get() call as part of a unit of work, and subsequently
backed out.
The default value is zero.
characterSet
public int characterSet
This specifies the coded character set identifier of character data in the
application message data. The behavior of the readString, readLine and
writeString methods is altered accordingly.
119
MQMessage
The default value for this field is MQC.MQCCSI_Q_MGR. If the default
value is used, CharacterSet 819 (iso-8859-1/latin/ibm819) is assumed. The
character set values you can use will depend upon the JVM you use.
Table 13 shows coded character set identifiers and the characterSet values
to use:
Table 13. Character set identifiers
120
characterSet
Description
37
437
500
819
1200
1208
273
277
278
280
284
285
297
420
424
737
775
813
838
850
852
855
856
857
860
861
862
863
864
865
866
868
869
870
871
874
875
912
913
914
915
916
918
920
921
922
930
ibm037
ibm437 / PC Original
ibm500
iso-8859-1 / latin1 / ibm819
Unicode
UTF-8
ibm273
ibm277
ibm278
ibm280
ibm284
ibm285
ibm297
ibm420
ibm424
ibm737 / PC Greek
ibm775 / PC Baltic
iso-8859-7 / greek / ibm813
ibm838
ibm850 / PC Latin 1
ibm852 / PC Latin 2
ibm855 / PC Cyrillic
ibm856
ibm857 / PC Turkish
ibm860 / PC Portuguese
ibm861 / PC Icelandic
ibm862 / PC Hebrew
ibm863 / PC Canadian French
ibm864 / PC Arabic
ibm865 / PC Nordic
ibm866 / PC Russian
ibm868
ibm869 / PC Modern Greek
ibm870
ibm871
ibm874
ibm875
iso-8859-2 / latin2 / ibm912
iso-8859-3 / latin3 / ibm913
iso-8859-4 / latin4 / ibm914
iso-8859-5 / cyrillic / ibm915
iso-8859-8 / hebrew / ibm916
ibm918
iso-8859-9 / latin5 / ibm920
ibm921
ibm922
ibm930
MQMessage
Table 13. Character set identifiers (continued)
characterSet
Description
932
933
935
937
939
942
948
949
950
954
964
970
1006
1025
1026
1089
1097
1098
1112
1122
1123
1124
1250
1251
1252
1253
1254
1255
1256
1257
1258
1381
1383
2022
5601
33722
PC Japanese
ibm933
ibm935
ibm937
ibm939
ibm942
ibm948
ibm949
ibm950 / Big 5 Traditional Chinese
EUCJIS
ibm964 / CNS 11643 Traditional Chinese
ibm970
ibm1006
ibm1025
ibm1026
iso-8859-6 / arabic / ibm1089
ibm1097
ibm1098
ibm1112
ibm1122
ibm1123
ibm1124
Windows Latin 2
Windows Cyrillic
Windows Latin 1
Windows Greek
Windows Turkish
Windows Hebrew
Windows Arabic
Windows Baltic
Windows Vietnamese
ibm1381
ibm1383
JIS
ksc-5601 Korean
ibm33722
correlationId
public byte correlationId[]
For an MQQueue.get() call, this field specifies the correlation identifier of
the message to be retrieved. Normally the queue manager returns the first
message with a message identifier and correlation identifier that match
those specified. The special value MQC.MQCI_NONE allows any
correlation identifier to match.
For an MQQueue.put() call, this specifies the correlation identifier to use.
The default value is MQC.MQCI_NONE.
encoding
public int encoding
This member variable specifies the representation used for numeric values
in the application message data; this applies to binary, packed decimal, and
Chapter 9. The WebSphere MQ base Java classes and interfaces
121
MQMessage
floating point data. The behavior of the read and write methods for these
numeric formats is altered accordingly.
The following encodings are defined for binary integers:
MQC.MQENC_INTEGER_NORMAL
Big-endian integers, as in Java
MQC.MQENC_INTEGER_REVERSED
Little-endian integers, as used by PCs.
The following encodings are defined for packed-decimal integers:
MQC.MQENC_DECIMAL_NORMAL
Big-endian packed-decimal, as used by z/OS.
MQC.MQENC_DECIMAL_REVERSED
Little-endian packed-decimal.
The following encodings are defined for floating-point numbers:
MQC.MQENC_FLOAT_IEEE_NORMAL
Big-endian IEEE floats, as in Java.
MQC.MQENC_FLOAT_IEEE_REVERSED
Little-endian IEEE floats, as used by PCs.
MQC.MQENC_FLOAT_S390
z/OS format floating points.
A value for the encoding field should be constructed by adding together
one value from each of these three sections (or using the bitwise OR
operator). The default value is:
MQC.MQENC_INTEGER_NORMAL |
MQC.MQENC_DECIMAL_NORMAL |
MQC.MQENC_FLOAT_IEEE_NORMAL
122
MQMessage
v
v
v
v
v
v
v
v
v
v
v
v
MQC.MQFB_EXPIRATION
MQC.MQFB_COA
MQC.MQFB_COD
MQC.MQFB_QUIT
MQC.MQFB_PAN
MQC.MQFB_NAN
MQC.MQFB_DATA_LENGTH_ZERO
MQC.MQFB_DATA_LENGTH_NEGATIVE
MQC.MQFB_DATA_LENGTH_TOO_BIG
MQC.MQFB_BUFFER_OVERFLOW
MQC.MQFB_LENGTH_OFF_BY_ONE
MQC.MQFB_IIH_ERROR
123
MQMessage
A byte string that identifies the message group to which the physical
message belongs.
The default value is MQC.MQGI_NONE.
messageFlags
public int messageFlags
Flags controlling the segmentation and status of a message.
messageId
public byte messageId[]
For an MQQueue.get() call, this field specifies the message identifier of the
message to be retrieved. Normally, the queue manager returns the first
message with a message identifier and correlation identifier that match
those specified. The special value MQC.MQMI_NONE allows any message
identifier to match.
For an MQQueue.put() call, this specifies the message identifier to use. If
MQC.MQMI_NONE is specified, the queue manager generates a unique
message identifier when the message is put. The value of this member
variable is updated after the put to indicate the message identifier that was
used.
The default value is MQC.MQMI_NONE.
messageSequenceNumber
public int messageSequenceNumber
The sequence number of a logical message within a group.
messageType
public int messageType
Indicates the type of the message. The following values are currently
defined by the system:
v MQC.MQMT_DATAGRAM
v MQC.MQMT_REPLY
v MQC.MQMT_REPORT
v MQC.MQMT_REQUEST
Application-defined values can also be used. These should be in the range
MQC.MQMT_APPL_FIRST to MQC.MQMT_APPL_LAST.
The default value of this field is MQC.MQMT_DATAGRAM.
offset
originalLength
public int originalLength
The original length of a segmented message.
persistence
public int persistence
Message persistence. The following values are defined:
v MQC.MQPER_NOT_PERSISTENT
v MQC.MQPER_PERSISTENT
v MQC.MQPER_PERSISTENCE_AS_Q_DEF
124
MQMessage
The default value is MQC.MQPER_PERSISTENCE_AS_Q_DEF, which
indicates that the persistence for the message should be taken from the
default persistence attribute of the destination queue.
priority
public int priority
The message priority. The special value
MQC.MQPRI_PRIORITY_AS_Q_DEF can also be set in outbound
messages, in which case the priority for the message is taken from the
default priority attribute of the destination queue.
The default value is MQC.MQPRI_PRIORITY_AS_Q_DEF.
putApplicationName
public String putApplicationName
The name of the application that put the message. The default value is .
putApplicationType
public int putApplicationType
The type of application that put the message. This may be a
system-defined or user-defined value. The following values are defined by
the system:
v MQC.MQAT_AIX
v MQC.MQAT_CICS
v MQC.MQAT_DOS
v MQC.MQAT_IMS
v MQC.MQAT_MVS
v MQC.MQAT_OS2
v MQC.MQAT_OS400
v MQC.MQAT_QMGR
v MQC.MQAT_UNIX
v MQC.MQAT_WINDOWS
v MQC.MQAT_JAVA
The default value is the special value MQC.MQAT_NO_CONTEXT, which
indicates that no context information is present in the message.
putDateTime
public GregorianCalendar putDateTime
The time and date that the message was put.
replyToQueueManagerName
public String replyToQueueManagerName
The name of the queue manager to which reply or report messages should
be sent.
The default value is .
If the value is on an MQQueue.put() call, the QueueManager fills in the
value.
replyToQueueName
public String replyToQueueName
The name of the message queue to which the application that issued the
get request for the message should send MQC.MQMT_REPLY and
MQC.MQMT_REPORT messages.
The default value is .
Chapter 9. The WebSphere MQ base Java classes and interfaces
125
MQMessage
report public int report
A report is a message about another message. This member variable
enables the application sending the original message to specify which
report messages are required, whether the application message data is to
be included in them, and also how the message and correlation identifiers
in the report or reply are to be set. Any, all or none of the following report
types can be requested:
v Exception
v Expiration
v Confirm on arrival
v Confirm on delivery
For each type, only one of the three corresponding values below should be
specified, depending on whether the application message data is to be
included in the report message.
Note: Values marked with ** in the following list are not supported by
MVS queue managers and should not be used if your application
is likely to access an MVS queue manager, regardless of the platform
on which the application is running.
The valid values are:
v MQC.MQRO_COA
v MQC.MQRO_COA_WITH_DATA
v MQC.MQRO_COA_WITH_FULL_DATA**
v MQC.MQRO_COD
v MQC.MQRO_COD_WITH_DATA
v MQC.MQRO_COD_WITH_FULL_DATA**
v MQC.MQRO_EXCEPTION
v MQC.MQRO_EXCEPTION_WITH_DATA
v MQC.MQRO_EXCEPTION_WITH_FULL_DATA**
v MQC.MQRO_EXPIRATION
v MQC.MQRO_EXPIRATION_WITH_DATA
v MQC.MQRO_EXPIRATION_WITH_FULL_DATA**
You can specify one of the following to control how the message Id is
generated for the report or reply message:
v MQC.MQRO_NEW_MSG_ID
v MQC.MQRO_PASS_MSG_ID
You can specify one of the following to control how the correlation Id of
the report or reply message is to be set:
v MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID
v MQC.MQRO_PASS_CORREL_ID
You can specify one of the following to control the disposition of the
original message when it cannot be delivered to the destination queue:
v MQC.MQRO_DEAD_LETTER_Q
v MQC.MQRO_DISCARD_MSG **
If no report options are specified, the default is:
MQC.MQRO_NEW_MSG_ID |
MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID |
MQC.MQRO_DEAD_LETTER_Q
126
MQMessage
You can specify one or both of the following to request that the receiving
application send a positive action or negative action report message.
v MQRO_PAN
v MQRO_NAN
userId public String userId
Part of the identity context of the message; it identifies the user that
originated this message.
The default value is .
Constructors
MQMessage
public MQMessage()
Create a new message with default message descriptor information and an
empty message buffer.
Methods
clearMessage
public void clearMessage()
Throws IOException.
Discard any data in the message buffer and set the data offset back to zero.
getDataLength
public int getDataLength()
Throws MQException.
The number of bytes of message data remaining to be read.
getDataOffset
public int getDataOffset()
Throws IOException.
Return the current cursor position within the message data (the point at
which read and write operations take effect).
getMessageLength
public int getMessageLength
Throws IOException.
The number of bytes of message data in this MQMessage object.
getTotalMessageLength
public int getTotalMessageLength()
The total number of bytes in the message as stored on the message queue
from which this message was retrieved (or attempted to be retrieved).
When an MQQueue.get() method fails with a message-truncated error
code, this method tells you the total size of the message on the queue.
See also MQQueue.get on page 149.
Chapter 9. The WebSphere MQ base Java classes and interfaces
127
MQMessage
getVersion
public int getVersion()
Returns the version of the structure in use.
readBoolean
public boolean readBoolean()
Throws IOException.
Read a (signed) byte from the current position in the message buffer.
readChar
public char readChar()
128
MQMessage
Read a double from the current position in the message buffer. The value
of the encoding member variable determines the behavior of this method.
Values of MQC.MQENC_FLOAT_IEEE_NORMAL and
MQC.MQENC_FLOAT_IEEE_REVERSED read IEEE standard doubles in
big-endian and little-endian formats respectively.
A value of MQC.MQENC_FLOAT_S390 reads a System/390 format floating
point number.
readFloat
public float readFloat()
129
MQMessage
Synonym for readShort(), provided for cross-language WebSphere MQ API
compatibility.
readInt4
public int readInt4()
Throws IOException.
Converts from the codeset identified in the characterSet member variable
to Unicode, and then reads in a line that has been terminated by \n, \r,
\r\n, or EOF.
readLong
public long readLong()
130
MQMessage
Read a string in the codeset identified by the characterSet member
variable, and convert it into Unicode.
Parameters:
length
readUInt2
public int readUInt2()
Throws IOException.
Read a UTF string, prefixed by a 2-byte length field, from the current
position in the message buffer.
resizeBuffer
public void resizeBuffer(int size)
Throws IOException.
A hint to the MQMessage object about the size of buffer that may be
required for subsequent get operations. If the message currently contains
message data, and the new size is less than the current size, the message
data is truncated.
seek
public void seek(int pos)
131
MQMessage
Throws IOException.
Move the cursor to the absolute position in the message buffer given by
pos. Subsequent reads and writes will act at this position in the buffer.
Throws EOFException if pos is outside the message data length.
setDataOffset
public void setDataOffset(int offset)
Throws IOException.
Move the cursor to the absolute position in the message buffer. This
method is a synonym for seek(), and is provided for cross-language
compatibility with the other WebSphere MQ APIs.
setVersion
public void setVersion(int version)
Throws IOException.
Write a byte into the message buffer at the current position.
write
public void write(byte b[])
Throws IOException.
Write an array of bytes into the message buffer at the current position.
write
132
MQMessage
public void write(byte b[],
int off,
int len)
Throws IOException.
Write a series of bytes into the message buffer at the current position. len
bytes will be written, taken from offset off in the array b.
writeBoolean
public void writeBoolean(boolean v)
Throws IOException.
Write a boolean into the message buffer at the current position.
writeByte
public void writeByte(int v)
Throws IOException.
Write a byte into the message buffer at the current position.
writeBytes
public void writeBytes(String s)
Throws IOException.
Writes out the string to the message buffer as a sequence of bytes. Each
character in the string is written out in sequence by discarding its high
eight bits.
writeChar
public void writeChar(int v)
Throws IOException.
Write a Unicode character into the message buffer at the current position.
writeChars
public void writeChars(String s)
Throws IOException.
Write a string as a sequence of Unicode characters into the message buffer
at the current position.
writeDecimal2
public void writeDecimal2(short v)
Throws IOException.
Write a 2-byte packed decimal format number into the message buffer at
the current position. The value of the encoding member variable
determines the behavior of this method.
133
MQMessage
A value of MQC.MQENC_DECIMAL_NORMAL writes a big-endian
packed decimal, a value of MQC.MQENC_DECIMAL_REVERSED writes a
little-endian packed decimal.
Parameters
v
writeDecimal4
public void writeDecimal4(int v)
Throws IOException.
Write a 4-byte packed decimal format number into the message buffer at
the current position. The value of the encoding member variable
determines the behavior of this method.
A value of MQC.MQENC_DECIMAL_NORMAL writes a big-endian
packed decimal, a value of MQC.MQENC_DECIMAL_REVERSED writes a
little-endian packed decimal.
Parameters
v
writeDecimal8
public void writeDecimal8(long v)
Throws IOException.
Write an 8-byte packed decimal format number into the message buffer at
the current position. The value of the encoding member variable
determines the behavior of this method.
A value of MQC.MQENC_DECIMAL_NORMAL writes a big-endian
packed decimal, a value of MQC.MQENC_DECIMAL_REVERSED writes a
little-endian packed decimal.
Parameters:
v
writeDouble
public void writeDouble(double v)
Throws IOException
Write a double into the message buffer at the current position. The value of
the encoding member variable determines the behavior of this method.
Values of MQC.MQENC_FLOAT_IEEE_NORMAL and
MQC.MQENC_FLOAT_IEEE_REVERSED write IEEE standard floats in
Big-endian and Little-endian formats respectively.
A value of MQC.MQENC_FLOAT_S390 writes a System/390 format
floating point number. Note that the range of IEEE doubles is greater than
the range of S/390 double precision floating point numbers, and so very
large numbers cannot be converted.
134
MQMessage
writeFloat
public void writeFloat(float v)
Throws IOException.
Write a float into the message buffer at the current position. The value of
the encoding member variable determines the behavior of this method.
Values of MQC.MQENC_FLOAT_IEEE_NORMAL and
MQC.MQENC_FLOAT_IEEE_REVERSED write IEEE standard floats in
big-endian and little-endian formats respectively.
A value of MQC.MQENC_FLOAT_S390 will write a System/390 format
floating point number.
writeInt
public void writeInt(int v)
Throws IOException.
Write an integer into the message buffer at the current position. The value
of the encoding member variable determines the behavior of this method.
A value of MQC.MQENC_INTEGER_NORMAL writes a big-endian
integer, a value of MQC.MQENC_INTEGER_REVERSED writes a
little-endian integer.
writeInt2
public void writeInt2(int v)
Throws IOException.
Synonym for writeShort(), provided for cross-language WebSphere MQ API
compatibility.
writeInt4
public void writeInt4(int v)
Throws IOException.
Synonym for writeInt(), provided for cross-language WebSphere MQ API
compatibility.
writeInt8
public void writeInt8(long v)
Throws IOException.
Synonym for writeLong(), provided for cross-language WebSphere MQ API
compatibility.
writeLong
public void writeLong(long v)
Throws IOException.
135
MQMessage
Write a long into the message buffer at the current position. The value of
the encoding member variable determines the behavior of this method.
A value of MQC.MQENC_INTEGER_NORMAL writes a big-endian long, a
value of MQC.MQENC_INTEGER_REVERSED writes a little-endian long.
writeObject
public void writeObject(Object obj)
Throws IOException.
Write the specified object to the message buffer. The class of the object, the
signature of the class, and the values of the non-transient and non-static
fields of the class and all its supertypes are all written.
writeShort
public void writeShort(int v)
Throws IOException.
Write a short into the message buffer at the current position. The value of
the encoding member variable determines the behavior of this method.
A value of MQC.MQENC_INTEGER_NORMAL writes a big-endian short,
a value of MQC.MQENC_INTEGER_REVERSED writes a little-endian
short.
writeString
public void writeString(String str)
Throws IOException.
Write a string into the message buffer at the current position, converting it
to the codeset identified by the characterSet member variable.
writeUTF
public void writeUTF(String str)
Throws IOException.
Write a UTF string, prefixed by a 2-byte length field, into the message
buffer at the current position.
136
MQMessageTracker
MQMessageTracker
java.lang.Object
com.ibm.mq.MQMessageTracker
Variables
accountingToken
public byte accountingToken[]
This is part of the identity context of the message. It allows an application
to cause work done as a result of the message to be appropriately charged.
The default value is MQC.MQACT_NONE.
correlationId
public byte correlationId[]
This specifies the correlation identifier to use when the message is put.
The default value is MQC.MQCI_NONE.
feedback
public int feedback
This is used with a message of type MQC.MQMT_REPORT to indicate the
nature of the report. The following feedback codes are defined by the
system:
v MQC.MQFB_BUFFER_OVERFLOW
v MQC.MQFB_COA
v MQC.MQFB_COD
v MQC.MQFB_DATA_LENGTH_NEGATIVE
v MQC.MQFB_DATA_LENGTH_TOO_BIG
v MQC.MQFB_DATA_LENGTH_ZERO
v MQC.MQFB_EXPIRATION
v MQC.MQFB_IIH_ERROR
v MQC.MQFB_LENGTH_OFF_BY_ONE
v MQC.MQFB_NAN
v MQC.MQFB_NONE
v MQC.MQFB_PAN
v MQC.MQFB_QUIT
Application defined feedback values in the range
MQC.MQFB_APPL_FIRST to MQC.MQFB_APPL_LAST can also be used.
The default value of this field is MQC.MQFB_NONE, indicating that no
feedback is provided.
groupId
public byte[] groupId
Chapter 9. The WebSphere MQ base Java classes and interfaces
137
MQMessageTracker
A byte string that identifies the message group to which the physical
message belongs.
The default value is MQC.MQGI_NONE.
messageId
public byte messageId[]
This specifies the message identifier to use when the message is put. If
MQC.MQMI_NONE is specified, the queue manager generates a unique
message identifier when the message is put. The value of this member
variable is updated after the put to indicate the message identifier that was
used.
The default value is MQC.MQMI_NONE.
138
MQPoolServices
MQPoolServices
java.lang.Object
com.ibm.mq.MQPoolServices
Constructors
MQPoolServices
public MQPoolServices()
Methods
addMQPoolServicesEventListener
public void addMQPoolServicesEventListener
(MQPoolServicesEventListener listener)
Remove an MQPoolServicesEventListener.
139
MQPoolServicesEvent
MQPoolServicesEvent
java.lang.Object
java.util.EventObject
com.ibm.mq.MQPoolServicesEvent
Variables
DEFAULT_POOL_CHANGED
public static final int DEFAULT_POOL_CHANGED
The event ID used when the default ConnectionManager changes.
ID
protected int ID
The event ID. Valid values are:
TOKEN_ADDED
TOKEN_REMOVED
DEFAULT_POOL_CHANGED
TOKEN_ADDED
public static final int TOKEN_ADDED
The event ID used when an MQPoolToken is added to the set.
TOKEN_REMOVED
public static final int TOKEN_REMOVED
The event ID used when an MQPoolToken is removed from the set.
token protected MQPoolToken token
The token. When the event ID is DEFAULT_POOL_CHANGED, this is
null.
Constructors
MQPoolServicesEvent
public MQPoolServicesEvent(Object source, int eid)
140
MQPoolServicesEvent
Methods
getId
getToken
public MQPoolToken getToken()
Returns the token that was added to, or removed from, the set. If the event
ID is DEFAULT_POOL_CHANGED, this is null.
141
MQPoolToken
MQPoolToken
java.lang.Object
com.ibm.mq.MQPoolToken
Constructors
MQPoolToken
public MQPoolToken()
142
MQProcess
MQProcess
java.lang.Object
com.ibm.mq.MQManagedObject
com.ibm.mq.MQProcess
Constructors
MQProcess
public MQProcess(MQQueueManager qMgr,
String processName,
int openOptions,
String queueManagerName,
String alternateUserId)
throws MQException
Methods
close
public synchronized void close()
Throws MQException.
Override of MQManagedObject.close on page 117.
getApplicationId
public String getApplicationId()
A character string that identifies the application to be started. This
information is for use by a trigger monitor application that processes
messages on the initiation queue; the information is sent to the initiation
queue as part of the trigger message.
Throws MQException if you call this method after you have closed the
process.
getApplicationType
public int getApplicationType()
Throws MQException (see page 110).
This identifies the nature of the program to be started in response to the
receipt of a trigger message. The application type can take any value, but
the following values are recommended for standard types:
v MQC.MQAT_AIX
v MQC.MQAT_CICS
v MQC.MQAT_DOS
v MQC.MQAT_IMS
v MQC.MQAT_MVS
v MQC.MQAT_OS2
Chapter 9. The WebSphere MQ base Java classes and interfaces
143
MQProcess
MQC.MQAT_OS400
MQC.MQAT_UNIX
MQC.MQAT_WINDOWS
MQC.MQAT_WINDOWS_NT
MQC.MWQAT_USER_FIRST (lowest value for user-defined application
type)
v MQC.MQAT_USER_LAST (highest value for user-defined application
type)
v
v
v
v
v
getEnvironmentData
public String getEnvironmentData()
Throws MQException.
A string containing environment-related information pertaining to the
application to be started.
getUserData
public String getUserData()
Throws MQException.
A string containing user information relevant to the application to be
started.
144
MQPutMessageOptions
MQPutMessageOptions
java.lang.Object
com.ibm.mq.MQPutMessageOptions
Variables
contextReference
public MQQueue ContextReference
This is an input field which indicates the source of the context information.
If the options field includes MQC.MQPMO_PASS_IDENTITY_CONTEXT,
or MQC.MQPMO_PASS_ALL_CONTEXT, set this field to refer to the
MQQueue from which the context information should be taken.
The initial value of this field is null.
invalidDestCount *
public int invalidDestCount
This is an output field set by the queue manager to the number of
messages that could not be sent to queues in a distribution list. The count
includes queues that failed to open as well as queues that were opened
successfully, but for which the put operation failed. This field is also set
when opening a single queue that is not part of a distribution list.
knownDestCount *
public int knownDestCount
This is an output field set by the queue manager to the number of
messages that the current call has sent successfully to queues that resolve
to local queues. This field is also set when opening a single queue that is
not part of a distribution list.
options
public int options
Options that control the action of MQQueue.put. Any or none of the
following values can be specified. If more than one option is required the
values can be added together or combined using the bitwise OR operator.
MQC.MQPMO_DEFAULT_CONTEXT
Associate default context with the message.
MQC.MQPMO_FAIL_IF_QUIESCING
Fail if the queue manager is quiescing.
MQC.MQPMO_LOGICAL_ORDER*
Put logical messages and segments in message groups into their
logical order.
Chapter 9. The WebSphere MQ base Java classes and interfaces
145
MQPutMessageOptions
MQC.MQPMO_NEW_CORREL_ID*
Generate a new correlation id for each sent message.
MQC.MQPMO_NEW_MSG_ID*
Generate a new message id for each sent message.
MQC.MQPMO_NONE
No options specified. Do not use in conjunction with other options.
MQC.MQPMO_NO_CONTEXT
No context is to be associated with the message.
MQC.MQPMO_NO_SYNCPOINT
Put a message without syncpoint control. Note that, if the
syncpoint control option is not specified, a default of no
syncpoint is assumed. This applies for all supported platforms,
including z/OS.
MQC.MQPMO_PASS_ALL_CONTEXT
Pass all context from an input queue handle.
MQC.MQPMO_PASS_IDENTITY_CONTEXT
Pass identity context from an input queue handle.
MQC.MQPMO_SET_ALL_CONTEXT
Set all context from the application.
MQC.MQPMO_SET_IDENTITY_CONTEXT
Set identity context from the application.
MQC.MQPMO_SYNCPOINT
Put a message with syncpoint control. The message is not visible
outside the unit of work until the unit of work is committed. If the
unit of work is backed out, the message is deleted.
recordFields *
public int recordFields
Flags indicating which fields are to be customized on a per-queue basis
when putting a message to a distribution list. One or more of the following
flags can be specified:
MQC.MQPMRF_ACCOUNTING_TOKEN
Use the accountingToken attribute in the MQDistributionListItem.
MQC.MQPMRF_CORREL_ID
Use the correlationId attribute in the MQDistributionListItem.
MQC.MQPMRF_FEEDBACK
Use the feedback attribute in the MQDistributionListItem.
MQC.MQPMRF_GROUP_ID
Use the groupId attribute in the MQDistributionListItem.
MQC.MQPMRF_MSG_ID
Use the messageId attribute in the MQDistributionListItem.
The special value MQC.MQPMRF_NONE indicates that no fields are to be
customized.
resolvedQueueManagerName
public String resolvedQueueManagerName
This is an output field set by the queue manager to the name of the queue
manager that owns the queue specified by the remote queue name. This
146
MQPutMessageOptions
may be different from the name of the queue manager from which the
queue was accessed if the queue is a remote queue.
resolvedQueueName
public String resolvedQueueName
This is an output field that is set by the queue manager to the name of the
queue on which the message is placed. This may be different from the
name used to open the queue if the opened queue was an alias or model
queue.
unknownDestCount *
public int unknownDestCount
This is an output field set by the queue manager to the number of
messages that the current call has sent successfully to queues that resolve
to remote queues. This field is also set when opening a single queue that is
not part of a distribution list.
Constructors
MQPutMessageOptions
public MQPutMessageOptions()
Construct a new MQPutMessageOptions object with no options set, and a
blank resolvedQueueName and resolvedQueueManagerName.
147
MQQueue
MQQueue
java.lang.Object
com.ibm.mq.MQManagedObject
com.ibm.mq.MQQueue
Constructors
MQQueue
public MQQueue(MQQueueManager qMgr, String queueName, int openOptions,
String queueManagerName, String dynamicQueueName,
String alternateUserId )
throws MQException
Methods
close
public synchronized void close()
Throws MQException.
Override of MQManagedObject.close on page 117.
get
public synchronized void get(MQMessage message,
MQGetMessageOptions getMessageOptions,
int MaxMsgSize)
Throws MQException.
Retrieves a message from the queue, up to a maximum specified message
size.
This method takes an MQMessage object as a parameter. It uses some of
the fields in the object as input parameters - in particular the messageId
and correlationId, so it is important to ensure that these are set as required.
(See Message on page 305.)
If the get fails, the MQMessage object is unchanged. If it succeeds the
message descriptor (member variables) and message data portions of the
MQMessage are completely replaced with the message descriptor and
message data from the incoming message.
148
MQQueue
Note that all calls to WebSphere MQ from a given MQQueueManager are
synchronous. Therefore, if you perform a get with wait, all other threads
using the same MQQueueManager are blocked from making further
WebSphere MQ calls until the get completes. If you need multiple threads
to access WebSphere MQ simultaneously, each thread must create its own
MQQueueManager object.
Parameters
message
An input/output parameter containing the message descriptor
information and the returned message data.
getMessageOptions
Options controlling the action of the get. (See
MQGetMessageOptions on page 112.)
Using option MQC.MQGMO_CONVERT may result in an
exception with reason code
MQException.MQRC_CONVERTED_STRING_TOO_BIG when
converting from single byte character codes to double byte codes.
In this case, the message will be copied into the buffer but will
remain encoded using its original character set.
MaxMsgSize
The largest message this call will be able to receive. If the message
on the queue is larger than this size, one of two things can occur:
1. If the MQC.MQGMO_ACCEPT_TRUNCATED_MSG flag is set
in the options member variable of the MQGetMessageOptions
object, the message is filled with as much of the message data
as will fit in the specified buffer size, and an exception is
thrown with completion code MQException.MQCC_WARNING
and reason code
MQException.MQRC_TRUNCATED_MSG_ACCEPTED.
2. If the MQC.MQGMO_ACCEPT_TRUNCATED_MSG flag is not
set, the message is left on the queue and an MQException is
raised with completion code MQException.MQCC_WARNING
and reason code
MQException.MQRC_TRUNCATED_MSG_FAILED.
Throws MQException if the get fails.
get
public synchronized void get(MQMessage message,
MQGetMessageOptions getMessageOptions)
Throws MQException.
Retrieves a message from the queue, regardless of the size of the message.
For large messages, the get method may have to issue two calls to
WebSphere MQ on your behalf, one to establish the required buffer size
and one to get the message data itself.
This method takes an MQMessage object as a parameter. It uses some of
the fields in the object as input parameters - in particular the messageId
and correlationId, so it is important to ensure that these are set as required.
(See Message on page 305.)
149
MQQueue
If the get fails, the MQMessage object is unchanged. If it succeeds, the
message descriptor (member variables) and message data portions of the
MQMessage are completely replaced with the message descriptor and
message data from the incoming message.
Note that all calls to WebSphere MQ from a given MQQueueManager are
synchronous. Therefore, if you perform a get with wait, all other threads
using the same MQQueueManager are blocked from making further
WebSphere MQ calls until the get completes. If you need multiple threads
to access WebSphere MQ simultaneously, each thread must create its own
MQQueueManager object.
Parameters
message
An input/output parameter containing the message descriptor
information and the returned message data.
getMessageOptions
Options controlling the action of the get. (See
MQGetMessageOptions on page 112 for details.)
Throws MQException if the get fails.
get
public synchronized void get(MQMessage message)
Throws MQException.
The date and time that this queue was created.
getQueueType
public int getQueueType()
Throws MQException
Returns
The type of this queue with one of the following values:
v MQC.MQQT_ALIAS
v MQC.MQQT_LOCAL
v MQC.MQQT_REMOTE
v MQC.MQQT_CLUSTER
getCurrentDepth
public int getCurrentDepth()
150
MQQueue
Throws MQException.
Get the number of messages currently on the queue. This value is
incremented during a put call, and during backout of a get call. It is
decremented during a non-browse get and during backout of a put call.
getDefinitionType
public int getDefinitionType()
Throws MQException.
Indicates how the queue was defined.
Returns
One of the following:
v MQC.MQQDT_PREDEFINED
v MQC.MQQDT_PERMANENT_DYNAMIC
v MQC.MQQDT_TEMPORARY_DYNAMIC
getInhibitGet
public int getInhibitGet()
Throws MQException.
Indicates whether or not get operations are allowed for this queue.
Returns
The possible values are:
v MQC.MQQA_GET_INHIBITED
v MQC.MQQA_GET_ALLOWED
getInhibitPut
public int getInhibitPut()
Throws MQException.
Indicates whether or not put operations are allowed for this queue.
Returns
One of the following:
v MQC.MQQA_PUT_INHIBITED
v MQC.MQQA_PUT_ALLOWED
getMaximumDepth
public int getMaximumDepth()
Throws MQException.
The maximum number of messages that can exist on the queue at any one
time. An attempt to put a message to a queue that already contains this
many messages fails with reason code MQException.MQRC_Q_FULL.
getMaximumMessageLength
public int getMaximumMessageLength()
Throws MQException.
151
MQQueue
This is the maximum length of the application data that can exist in each
message on this queue. An attempt to put a message larger than this value
fails with reason code MQException.MQRC_MSG_TOO_BIG_FOR_Q.
getOpenInputCount
public int getOpenInputCount()
Throws MQException.
The number of handles that are currently valid for removing messages
from the queue. This is the total number of such handles known to the
local queue manager, not just those created by the WebSphere MQ classes
for Java (using accessQueue).
getOpenOutputCount
public int getOpenOutputCount()
Throws MQException.
The number of handles that are currently valid for adding messages to the
queue. This is the total number of such handles known to the local queue
manager, not just those created by the WebSphere MQ classes for Java
(using accessQueue).
getShareability
public int getShareability()
Throws MQException.
Indicates whether the queue can be opened for input multiple times.
Returns
One of the following:
v MQC.MQQA_SHAREABLE
v MQC.MQQA_NOT_SHAREABLE
getTriggerControl
public int getTriggerControl()
Throws MQException.
Indicates whether or not trigger messages are written to an initiation
queue, in order to cause an application to be started to service the queue.
Returns
The possible values are:
v MQC.MQTC_OFF
v MQC.MQTC_ON
getTriggerData
public String getTriggerData()
Throws MQException.
The free-format data that the queue manager inserts into the trigger
message when a message arriving on this queue causes a trigger message
to be written to the initiation queue.
getTriggerDepth
152
MQQueue
public int getTriggerDepth()
Throws MQException.
The number of messages that have to be on the queue before a trigger
message is written when trigger type is set to MQC.MQTT_DEPTH.
getTriggerMessagePriority
public int getTriggerMessagePriority()
Throws MQException.
This is the message priority below which messages do not contribute to the
generation of trigger messages (that is, the queue manager ignores these
messages when deciding whether a trigger should be generated). A value
of zero causes all messages to contribute to the generation of trigger
messages.
getTriggerType
public int getTriggerType()
Throws MQException.
The conditions under which trigger messages are written as a result of
messages arriving on this queue.
Returns
The possible values are:
v MQC.MQTT_NONE
v MQC.MQTT_FIRST
v MQC.MQTT_EVERY
v MQC.MQTT_DEPTH
put
public synchronized void put(MQMessage message,
MQPutMessageOptions putMessageOptions)
Throws MQException.
Places a message onto the queue.
Note: For simplicity and performance, if you want to put just a single
message to a queue, use the put() method on your
MQQueueManager object. For this you do not need to have an
MQQueue object. See MQQueueManager.put on page 167.
This method takes an MQMessage object as a parameter. The message
descriptor properties of this object may be altered as a result of this
method. The values they have immediately after the completion of this
method are the values that were put onto the WebSphere MQ queue.
Modifications to the MQMessage object after the put has completed do not
affect the actual message on the WebSphere MQ queue.
A put updates the messageId and correlationId. This must be considered
when making further calls to put/get using the same MQMessage object.
Also, calling put does not clear the message data, so:
153
MQQueue
msg.writeString("a");
q.put(msg,pmo);
msg.writeString("b");
q.put(msg,pmo);
puts two messages. The first contains a and the second ab.
Parameters
message
Message Buffer containing the Message Descriptor data and
message to be sent.
putMessageOptions
Options controlling the action of the put. (See
MQPutMessageOptions on page 145)
Throws MQException if the put fails.
put
public synchronized void put(MQMessage message)
Throws MQException.
Controls whether or not get operations are allowed for this queue. The
permissible values are:
v MQC.MQQA_GET_INHIBITED
v MQC.MQQA_GET_ALLOWED
setInhibitPut
public void setInhibitPut(int inhibit)
Throws MQException.
Controls whether or not put operations are allowed for this queue. The
permissible values are:
v MQC.MQQA_PUT_INHIBITED
v MQC.MQQA_PUT_ALLOWED
setTriggerControl
public void setTriggerControl(int trigger)
Throws MQException.
154
MQQueue
Controls whether or not trigger messages are written to an initiation
queue, in order to cause an application to be started to service the queue.
The permissible values are:
v MQC.MQTC_OFF
v MQC.MQTC_ON
setTriggerData
public void setTriggerData(String data)
Throws MQException.
Sets the free-format data that the queue manager inserts into the trigger
message when a message arriving on this queue causes a trigger message
to be written to the initiation queue. The maximum permissible length of
the string is given by MQC.MQ_TRIGGER_DATA_LENGTH.
setTriggerDepth
public void setTriggerDepth(int depth)
Throws MQException.
Sets the number of messages that have to be on the queue before a trigger
message is written when trigger type is set to MQC.MQTT_DEPTH.
setTriggerMessagePriority
public void setTriggerMessagePriority(int priority)
Throws MQException.
Sets the message priority below which messages do not contribute to the
generation of trigger messages (that is, the queue manager ignores these
messages when deciding whether a trigger should be generated). A value
of zero causes all messages to contribute to the generation of trigger
messages.
setTriggerType
public void setTriggerType(int type)
Throws MQException.
Sets the conditions under which trigger messages are written as a result of
messages arriving on this queue. The possible values are:
v MQC.MQTT_NONE
v MQC.MQTT_FIRST
v MQC.MQTT_EVERY
v MQC.MQTT_DEPTH
155
MQQueueManager
MQQueueManager
java.lang.Object
com.ibm.mq.MQManagedObject
com.ibm.mq.MQQueueManager
Variables
isConnected
public boolean isConnected
True if the connection to the queue manager is still open.
Constructors
MQQueueManager
public MQQueueManager(String queueManagerName)
Throws MQException.
Create a connection to the named queue manager.
Note: When using WebSphere MQ classes for Java, the hostname, channel
name and port to use during the connection request are specified in
the MQEnvironment class. This must be done before calling this
constructor.
The following example shows a connection to a queue manager MYQM,
running on a machine with hostname fred.mq.com.
MQEnvironment.hostname = "fred.mq.com"; // host to connect to
MQEnvironment.port
= 1414;
// port to connect to.
// If I dont set this,
// it defaults to 1414
// (the default WebSphere MQ port)
MQEnvironment.channel = "channel.name"; // the CASE-SENSITIVE
// name of the
// SVR CONN channel on
// the queue manager
MQQueueManager qMgr
= new MQQueueManager("MYQM");
156
MQQueueManager
MQQueueManager
public MQQueueManager(String queueManagerName,
MQConnectionManager cxManager)
Throws MQException.
This constructor connects to the specified Queue Manager, using the
properties in MQEnvironment. The specified MQConnectionManager
manages the connection.
MQQueueManager
public MQQueueManager(String queueManagerName,
ConnectionManager cxManager)
Throws MQException.
This constructor connects to the specified Queue Manager, using the
properties in MQEnvironment. The specified ConnectionManager manages
the connection.
This constructor requires a JVM at at least Java 2 v1.3, with at least JAAS
1.0 installed.
MQQueueManager
public MQQueueManager(String queueManagerName,
int options)
Throws MQException.
This version of the constructor is intended for use only in bindings mode
and it uses the extended connection API (MQCONNX) to connect to the
queue manager. The options parameter allows you to choose fast or normal
bindings. Possible values are:
v MQC.MQCNO_FASTPATH_BINDING for fast bindings *.
v MQC.MQCNO_STANDARD_BINDING for normal bindings.
MQQueueManager
public MQQueueManager(String queueManagerName,
int options,
MQConnectionManager cxManager)
Throws MQException.
This constructor performs an MQCONNX, passing the supplied options.
The specified MQConnectionManager manages the connection.
MQQueueManager
public MQQueueManager(String queueManagerName,
int options,
ConnectionManager cxManager)
Throws MQException.
This constructor performs an MQCONNX, passing the supplied options.
The specified ConnectionManager manages the connection.
This constructor requires a JVM at at least Java 2 v1.3, with at least JAAS
1.0 installed.
Chapter 9. The WebSphere MQ base Java classes and interfaces
157
MQQueueManager
MQQueueManager
public MQQueueManager(String queueManagerName,
java.util.Hashtable properties)
Throws MQException.
This constructor connects to the named Queue Manager, using the
supplied Hashtable of properties to override those in MQEnvironment. The
specified MQConnectionManager manages the connection.
MQQueueManager
public MQQueueManager(String queueManagerName,
Hashtable properties,
ConnectionManager cxManager)
Throws MQException.
This constructor connects to the named Queue Manager, using the
supplied Hashtable of properties to override those in MQEnvironment. The
specified ConnectionManager manages the connection.
This constructor requires a JVM at at least Java 2 v1.3, with at least JAAS
1.0 installed.
158
MQQueueManager
Methods
accessDistributionList
public synchronized MQDistributionList accessDistributionList
(
MQDistributionListItem[] litems, int openOptions,
String alternateUserId
)
Throws MQException.
Parameters
litems
openOptions
Options that control the opening of the distribution list.
alternateUserId
If MQOO_ALTERNATE_USER_AUTHORITY is specified in the
openOptions parameter, this parameter specifies the alternate user
identifier that is used to check the authorization for the open. If
MQOO_ALTERNATE_USER_AUTHORITY is not specified, this
parameter can be left blank (or null).
Returns
A newly created MQDistributionList which is open and ready for
put operations.
Throws MQException if the open fails.
See also MQQueueManager.accessQueue on page 161.
accessDistributionList
This is a simplified version of the AccessDistributionList method
previously described.
public synchronized MQDistributionList accessDistributionList
(
MQDistributionListItem[] litems,
int openOptions,
)
Parameters
litems
openOptions
Options that control the opening of the distribution list.
See accessDistributionList for details of the parameters.
alternateUserId is set to .
159
MQQueueManager
accessProcess
public synchronized MQProcess accessProcess
(
String processName,
int openOptions,
String queueManagerName,
String alternateUserId
)
Throws MQException.
Establishes access to a WebSphere MQ process on this queue manager to
inquire about the process attributes.
Parameters
processName
Name of process to open.
openOptions
Options that control the opening of the process. Inquire is
automatically added to the options specified, so there is no need to
specify it explicitly.
Valid options are:
MQC.MQOO_ALTERNATE_USER_AUTHORITY
Validate with the specified user id
MQC.MQOO_FAIL_IF_QUIESCING
Fail if the queue manager is quiescing
If more than one option is required, the values can be added
together or combined using the bitwise OR operator. See the
WebSphere MQ Application Programming Reference for a fuller
description of these options.
queueManagerName
Name of the queue manager on which the process is defined.
Applications should leave this parameter blank or null.
alternateUserId
If MQOO_ALTERNATE_USER_AUTHORITY is specified in the
openOptions parameter, this parameter specifies the alternate user
identifier that is used to check the authorization for the open. If
MQOO_ALTERNATE_USER_AUTHORITY is not specified, this
parameter can be left blank (or null).
accessProcess
This is a simplified version of the AccessProcess method previously
described.
public synchronized MQProcess accessProcess
(
String processName,
int openOptions
)
160
MQQueueManager
Parameters
processName
The name of the process to open.
openOptions
Options that control the opening of the process.
See accessProcess on page 160 for details of the options.
queueManagerName and alternateUserId are set to .
accessQueue
public synchronized MQQueue accessQueue
(
String queueName, int openOptions,
String queueManagerName,
String dynamicQueueName,
String alternateUserId
)
Throws MQException.
Establishes access to a WebSphere MQ queue on this queue manager to get
or browse messages, put messages, inquire about the attributes of the
queue or set the attributes of the queue.
If the queue named is a model queue, then a dynamic local queue is
created. The name of the created queue can be determined by inspecting
the name attribute of the returned MQQueue object.
Parameters
queueName
Name of queue to open.
openOptions
Options that control the opening of the queue. Valid options are:
MQC.MQOO_ALTERNATE_USER_AUTHORITY
Validate with the specified user identifier.
MQC.MQOO_BIND_AS_QDEF
Use default binding for queue.
MQC.MQOO_BIND_NOT_FIXED
Do not bind to a specific destination.
MQC.MQOO_BIND_ON_OPEN
Bind handle to destination when queue is opened.
MQC.MQOO_BROWSE
Open to browse message.
MQC.MQOO_FAIL_IF_QUIESCING
Fail if the queue manager is quiescing.
MQC.MQOO_INPUT_AS_Q_DEF
Open to get messages using queue-defined default.
MQC.MQOO_INPUT_SHARED
Open to get messages with shared access.
161
MQQueueManager
MQC.MQOO_INPUT_EXCLUSIVE
Open to get messages with exclusive access.
MQC.MQOO_INQUIRE
Open for inquiry - required if you wish to query
properties.
MQC.MQOO_OUTPUT
Open to put messages.
MQC.MQOO_PASS_ALL_CONTEXT
Allow all context to be passed.
MQC.MQOO_PASS_IDENTITY_CONTEXT
Allow identity context to be passed.
MQC.MQOO_SAVE_ALL_CONTEXT
Save context when message retrieved*.
MQC.MQOO_SET
Open to set attributes.
MQC.MQOO_SET_ALL_CONTEXT
Allows all context to be set.
MQC.MQOO_SET_IDENTITY_CONTEXT
Allows identity context to be set.
If more than one option is required, the values can be added
together or combined using the bitwise OR operator. See WebSphere
MQ Application Programming Reference for a fuller description of
these options.
queueManagerName
Name of the queue manager on which the queue is defined. A
name which is entirely blank, or which is null, denotes the queue
manager to which this MQQueueManager object is connected.
dynamicQueueName
This parameter is ignored unless queueName specifies the name of
a model queue. If it does, this parameter specifies the name of the
dynamic queue to be created. A blank or null name is not valid if
queueName specifies the name of a model queue. If the last
non-blank character in the name is an asterisk (*), the queue
manager replaces the asterisk with a string of characters that
guarantees that the name generated for the queue is unique on this
queue manager.
alternateUserId
If MQOO_ALTERNATE_USER_AUTHORITY is specified in the
openOptions parameter, this parameter specifies the alternate user
identifier that is used to check the authorization for the open. If
MQOO_ALTERNATE_USER_AUTHORITY is not specified, this
parameter can be left blank (or null).
Returns
MQQueue that has been successfully opened.
Throws MQException if the open fails.
162
MQQueueManager
accessQueue
public synchronized MQQueue accessQueue
(
String queueName,
int openOptions
)
Throws MQException if you call this method after disconnecting from the
queue manager.
Parameters
queueName
Name of queue to open
openOptions
Options that control the opening of the queue
See MQQueueManager.accessQueue on page 161 for details of the
parameters.
For this version of the method, queueManagerName, dynamicQueueName, and
alternateUserId are set to .
Returns
MQProcess that has been successfully opened.
Throws MQException if the open fails.
See also MQQueueManager.accessQueue on page 161.
backout
public synchronized void backout()
Throws MQException.
Calling this method indicates to the queue manager that all the message
gets and puts that have occurred since the last syncpoint are to be backed
out. Messages put as part of a unit of work (with the
MQC.MQPMO_SYNCPOINT flag set in the options field of
MQPutMessageOptions) are deleted; messages retrieved as part of a unit of
work (with the MQC.MQGMO_SYNCPOINT flag set in the options field of
MQGetMessageOptions) are reinstated on the queue.
See also the description of the commit method.
begin* (bindings connection only)
public synchronized void begin()
Throws MQException.
This method is supported only by the WebSphere MQ classes for Java in
bindings mode and it signals to the queue manager that a new unit of
work is starting.
Do not use this method for applications that use local one-phase
transactions.
163
MQQueueManager
commit
public synchronized void commit()
Throws MQException.
Calling this method indicates to the queue manager that the application
has reached a syncpoint, and that all of the message gets and puts that
have occurred since the last syncpoint are to be made permanent.
Messages put as part of a unit of work (with the
MQC.MQPMO_SYNCPOINT flag set in the options field of
MQPutMessageOptions) are made available to other applications. Messages
retrieved as part of a unit of work (with the MQC.MQGMO_SYNCPOINT
flag set in the options field of MQGetMessageOptions) are deleted.
See also the description of the backout method.
disconnect
public synchronized void disconnect()
Throws MQException.
Terminates the connection to the queue manager. All open queues and
processes accessed by this queue manager are closed, and hence become
unusable. When you have disconnected from a queue manager the only
way to reconnect is to create a new MQQueueManager object.
Normally, any work performed as part of a unit of work is committed.
However, if this connection is managed by a ConnectionManager, rather
than an MQConnectionManager, the unit of work might be rolled back.
getCharacterSet
public int getCharacterSet()
Throws MQException.
Returns the CCSID (Coded Character Set Identifier) of the queue
managers codeset. This defines the character set used by the queue
manager for all character string fields in the application programming
interface.
Throws MQException if you call this method after disconnecting from the
queue manager.
getCommandInputQueueName
public String getCommandInputQueueName()
Throws MQException.
Returns the name of the command input queue defined on the queue
manager. This is a queue to which applications can send commands, if
authorized to do so.
Throws MQException if you call this method after disconnecting from the
queue manager.
164
MQQueueManager
getCommandLevel
public int getCommandLevel()
Throws MQException.
Indicates the level of system control commands supported by the queue
manager. The set of system control commands that correspond to a
particular command level varies according to the architecture of the
platform on which the queue manager is running. See the WebSphere MQ
documentation for your platform for further details.
Throws MQException if you call this method after disconnecting from the
queue manager.
Returns
One of the MQC.MQCMDL_LEVEL_xxx constants
getDistributionListCapable
public boolean getDistributionListCapable()
password
The password to use for this connection to the database. This is
passed to the underlying XADataSource.getXAConnection method.
165
MQQueueManager
getJDBCConnection
public java.sql.Connection getJDBCConnection(javax.sql.XADataSource xads)
throws MQException, SQLException, Exception
getMaximumMessageLength
public int getMaximumMessageLength()
Throws MQException.
Returns the maximum length of a message (in bytes) that can be handled
by the queue manager. No queue can be defined with a maximum message
length greater than this.
Throws MQException if you call this method after disconnecting from the
queue manager.
getMaximumPriority
public int getMaximumPriority()
Throws MQException.
Returns the maximum message priority supported by the queue manager.
Priorities range from zero (lowest) to this value.
Throws MQException if you call this method after disconnecting from the
queue manager.
getSyncpointAvailability
public int getSyncpointAvailability()
Throws MQException.
Indicates whether the queue manager supports units of work and
syncpointing with the MQQueue.get and MQQueue.put methods.
166
MQQueueManager
Returns
v MQC.MQSP_AVAILABLE if syncpointing is available.
v MQC.MQSP_NOT_AVAILABLE if syncpointing is not available.
Throws MQException if you call this method after disconnecting from the
queue manager.
isConnected
public boolean isConnected()
pmo
altUserid
Specifies an alternative user identifier used to check authorization
when placing the message on a queue.
put
public synchronized void put(String qName,
String qmName,
MQMessage msg,
MQPutMessageOptions pmo)
throws MQException
167
MQQueueManager
put
public synchronized void put(String qName,
String qmName,
MQMessage msg)
throws MQException
168
MQSimpleConnectionManager
MQSimpleConnectionManager
java.lang.Object
com.ibm.mq.MQConnectionManager
com.ibm.mq.MQSimpleConnectionManager
Variables
MODE_ACTIVE
public static final int MODE_ACTIVE. See setActive on page 170.
MODE_AUTO
public static final int MODE_AUTO. See setActive on page 170.
MODE_INACTIVE
public static final int MODE_INACTIVE. See setActive on page 170.
Constructors
MQSimpleConnectionManager
public MQSimpleConnectionManager()
Constructs an MQSimpleConnectionManager.
Methods
getActive
public int getActive()
Gets the mode of the connection pool.
Returns
The current active mode of the connection pool, with one of the following
values (see setActive on page 170):
MODE_ACTIVE
MODE_AUTO
MODE_INACTIVE
getHighThreshold
public int getHighThreshold ()
Returns the HighThreshold value.
getTimeout
public long getTimeout()
Chapter 9. The WebSphere MQ base Java classes and interfaces
169
MQSimpleConnectionManager
Returns the Timeout value.
setActive
public void setActive(int mode)
Sets the active mode of the connection pool.
Parameters
mode
The required active mode of the connection pool. Valid values are:
MODE_ACTIVE
The connection pool is always active. When
MQQueueManager.disconnect() is called, the underlying
connection is pooled, and potentially reused the next time
that an MQQueueManager object is constructed.
Connections will be destroyed by a separate thread if they
are unused for longer than the Timeout period, or if the
size of the pool exceeds HighThreshold.
MODE_AUTO
The connection pool is active while the Connection
Manager is the default Connection Manager and there is at
least one token in the set of MQPoolTokens held by
MQEnvironment. This is the default mode.
MODE_INACTIVE
The connection pool is always inactive. When this mode is
entered, the pool of connections to WebSphere MQ is
cleared. When MQQueueManager.disconnect() is called, the
connection that underlies any active MQQueueManager
object is destroyed.
setHighThreshold
public void setHighThreshold(int threshold)
Sets the HighThreshold. If the number of unused connections in the pool
exceeds this value, the oldest unused connection in the pool is destroyed.
Parameters
threshold
The maximum number of unused connections in the pool.
setTimeout
public void setTimeout(long timeout)
Sets the Timeout value, where connections that remain unused for this
length of time are destroyed by a separate thread.
Parameters
timeout
The value of the timeout in milliseconds.
170
MQC
MQC
public interface MQC
extends Object
The MQC interface defines all the constants used by the WebSphere MQ Java
programming interface (except for completion code constants and error code
constants). To refer to one of these constants from within your programs, prefix the
constant name with MQC.. For example, you can set the close options for a
queue as follows:
MQQueue queue;
...
queue.closeOptions = MQC.MQCO_DELETE; // delete the
// queue when
// it is closed
...
171
MQPoolServicesEventListener
MQPoolServicesEventListener
public interface
extends Object
MQPoolServicesEventListener
Methods
defaultConnectionManagerChanged
public void defaultConnectionManagerChanged(MQPoolServicesEvent event)
172
MQConnectionManager
MQConnectionManager
This is a private interface that cannot be implemented by applications. WebSphere
MQ classes for Java supplies an implementation of this interface
(MQSimpleConnectionManager), which you can specify on the MQQueueManager
constructor, or through MQEnvironment.setDefaultConnectionManager.
See MQSimpleConnectionManager on page 169.
Applications or middleware that wish to provide their own ConnectionManager
should implement javax.resource.spi.ConnectionManager. This requires Java 2 v1.3
with JAAS 1.0 installed.
173
MQReceiveExit
MQReceiveExit
public interface MQReceiveExit
extends Object
The receive exit interface allows you to examine and possibly alter the data
received from the queue manager by the WebSphere MQ classes for Java.
Note: This interface does not apply when connecting directly to WebSphere MQ in
bindings mode.
To provide your own receive exit, define a class that implements this interface.
Create a new instance of your class and assign the MQEnvironment.receiveExit
variable to it before constructing your MQQueueManager object. For example:
// in MyReceiveExit.java
class MyReceiveExit implements MQReceiveExit {
// you must provide an implementation
// of the receiveExit method
public byte[] receiveExit(
MQChannelExit
channelExitParms,
MQChannelDefinition channelDefinition,
byte[]
agentBuffer)
{
// your exit code goes here...
}
}
// in your main program...
MQEnvironment.receiveExit = new MyReceiveExit();
...
// other initialization
MQQueueManager qMgr
= new MQQueueManager("");
Methods
receiveExit
public abstract byte[] receiveExit(MQChannelExit channelExitParms,
MQChannelDefinition channelDefinition,
byte agentBuffer[])
The receive exit method that your class must provide. This method will be
invoked whenever the WebSphere MQ classes for Java receives some data
from the queue manager.
Parameters
channelExitParms
Contains information regarding the context in which the exit is
being invoked. The exitResponse member variable is an output
parameter that you use to tell the WebSphere MQ classes for Java
what action to take next. See MQChannelExit on page 98 for
further details.
channelDefinition
Contains details of the channel through which all communications
with the queue manager take place.
agentBuffer
If the channelExitParms.exitReason is
MQChannelExit.MQXR_XMIT, agentBuffer contains the data
received from the queue manager; otherwise agentBuffer is null.
174
MQReceiveExit
Returns
If the exit response code (in channelExitParms) is set so that the
WebSphere MQ classes for Java can now process the data (MQXCC_OK),
your receive exit method must return the data to be processed. The
simplest receive exit, therefore, consists of the single line return
agentBuffer;.
See also:
v MQC on page 171
v MQChannelDefinition on page 96
175
MQSecurityExit
MQSecurityExit
public interface MQSecurityExit
extends Object
The security exit interface allows you to customize the security flows that occur
when an attempt is made to connect to a queue manager.
Note: This interface does not apply when connecting directly to WebSphere MQ in
bindings mode.
To provide your own security exit, define a class that implements this interface.
Create a new instance of your class and assign the MQEnvironment.securityExit
variable to it before constructing your MQQueueManager object. For example:
// in MySecurityExit.java
class MySecurityExit implements MQSecurityExit {
// you must provide an implementation
// of the securityExit method
public byte[] securityExit(
MQChannelExit
channelExitParms,
MQChannelDefinition channelDefinition,
byte[]
agentBuffer)
{
// your exit code goes here...
}
}
// in your main program...
MQEnvironment.securityExit = new MySecurityExit();
...
// other initialization
MQQueueManager qMgr
= new MQQueueManager("");
Methods
securityExit
public abstract byte[] securityExit(MQChannelExit channelExitParms,
MQChannelDefinition channelDefinition,
byte agentBuffer[])
176
MQSecurityExit
Returns
If the exit response code (in channelExitParms) is set so that a message is
to be transmitted to the queue manager, your security exit method must
return the data to be transmitted.
See also:
v MQC on page 171
v MQChannelDefinition on page 96
177
MQSendExit
MQSendExit
public interface MQSendExit
extends Object
The send exit interface allows you to examine and possibly alter the data sent to
the queue manager by the WebSphere MQ Client for Java.
Note: This interface does not apply when connecting directly to WebSphere MQ in
bindings mode.
To provide your own send exit, define a class that implements this interface. Create
a new instance of your class and assign the MQEnvironment.sendExit variable to it
before constructing your MQQueueManager object. For example:
// in MySendExit.java
class MySendExit implements MQSendExit {
// you must provide an implementation of the sendExit method
public byte[] sendExit(
MQChannelExit
channelExitParms,
MQChannelDefinition channelDefinition,
byte[]
agentBuffer)
{
// your exit code goes here...
}
}
// in your main program...
MQEnvironment.sendExit = new MySendExit();
...
// other initialization
MQQueueManager qMgr
= new MQQueueManager("");
Methods
sendExit
public abstract byte[] sendExit(MQChannelExit channelExitParms,
MQChannelDefinition channelDefinition,
byte agentBuffer[])
The send exit method that your class must provide. This method is
invoked whenever the WebSphere MQ classes for Java wishes to transmit
some data to the queue manager.
Parameters
channelExitParms
Contains information regarding the context in which the exit is
being invoked. The exitResponse member variable is an output
parameter that you use to tell the WebSphere MQ classes for Java
what action to take next. See MQChannelExit on page 98 for
further details.
channelDefinition
Contains details of the channel through which all communications
with the queue manager take place.
agentBuffer
If the channelExitParms.exitReason is
MQChannelExit.MQXR_XMIT, agentBuffer contains the data to be
transmitted to the queue manager; otherwise agentBuffer is null.
178
MQSendExit
Returns
If the exit response code (in channelExitParms) is set so that a message is
to be transmitted to the queue manager (MQXCC_OK), your send exit
method must return the data to be transmitted. The simplest send exit,
therefore, consists of the single line return agentBuffer;.
See also:
v MQC on page 171
v MQChannelDefinition on page 96
179
ManagedConnection
ManagedConnection
public interface javax.resource.spi.ManagedConnection
Note: Normally, applications do not use this class; it is intended for use by
implementations of ConnectionManager.
WebSphere MQ classes for Java provides an implementation of
ManagedConnection that is returned from
ManagedConnectionFactory.createManagedConnection. This object represents a
connection to a WebSphere MQ Queue Manager. For more details about this
interface, see the J2EE Connector Architecture specification (refer to Suns Web site
at http://java.sun.com).
Methods
addConnectionEventListener
public void addConnectionEventListener(ConnectionEventListener listener)
Throws ResourceException.
WebSphere MQ classes for Java does not currently support this method. A
javax.resource.NotSupportedException is thrown.
cleanup
public void cleanup()
Throws ResourceException.
Closes all open connection handles, and resets the physical connection to
an initial state ready to be pooled. Any pending local transaction is rolled
back. For more details, see getLocalTransaction on page 181.
destroy
public void destroy()
Throws ResourceException.
Destroys the physical connection to the WebSphere MQ Queue Manager.
Any pending local transaction is committed. For more details, see
getLocalTransaction on page 181.
getConnection
public Object getConnection(javax.security.auth.Subject subject,
ConnectionRequestInfo cxRequestInfo)
Throws ResourceException.
180
ManagedConnection
Creates a new connection handle for the physical connection represented
by the ManagedConnection object. For WebSphere MQ classes for Java, this
returns an MQQueueManager object. The ConnectionManager normally
returns this object from allocateConnection.
The subject parameter is ignored. If the cxRequestInfo parameter is not
suitable, a ResourceException is thrown. Multiple connection handles can
be used simultaneously for each single ManagedConnection.
getLocalTransaction
public LocalTransaction getLocalTransaction()
Throws ResourceException.
WebSphere MQ classes for Java does not currently support this method. A
javax.resource.NotSupportedException is thrown.
Currently, a ConnectionManager cannot manage the WebSphere MQ local
transaction, and registered ConnectionEventListeners are not informed
about events relating to the local transaction. When cleanup() occurs, any
ongoing unit of work is rolled back. When destroy() occurs, any ongoing
unit of work is committed.
Existing API behavior is that an ongoing unit of work is committed at
MQQueueManager.disconnect(). This existing behavior is preserved only
when an MQConnectionManager (rather than a ConnectionManager)
manages the connection.
getLogWriter
public java.io.PrintWriter getLogWriter()
Throws ResourceException.
Returns the log writer for this ManagedConnection.
WebSphere MQ classes for Java does not currently use the log writer. See
MQException.log on page 110 for more information about logging.
getMetaData
public ManagedConnectionMetaData getMetaData()
Throws ResourceException.
Gets the meta data information for the underlying Queue Manager. See
ManagedConnectionMetaData on page 185.
getXAResource
public javax.transaction.xa.XAResource getXAResource()
Throws ResourceException.
WebSphere MQ classes for Java does not currently support this method. A
javax.resource.NotSupportedException is thrown.
removeConnectionEventListener
public void removeConnectionEventListener(ConnectionEventListener listener)
181
ManagedConnection
setLogWriter
public void setLogWriter(java.io.PrintWriter out)
Throws ResourceException.
Sets the log writer for this ManagedConnection. When a
ManagedConnection is created, it inherits the log writer from its
ManagedConnectionFactory.
WebSphere MQ classes for Java does not currently use the log writer. See
MQException.log on page 110 for more information about logging.
182
ManagedConnectionFactory
ManagedConnectionFactory
public interface javax.resource.spi.ManagedConnectionFactory
Note: Normally, applications do not use this class; it is intended for use by
implementations of ConnectionManager.
WebSphere MQ classes for Java provides an implementation of this interface to
ConnectionManagers. A ManagedConnectionFactory is used to construct
ManagedConnections, and to select suitable ManagedConnections from a set of
candidates. For more details about this interface, see the J2EE Connector
Architecture specification (refer to Suns Web site at http://java.sun.com).
Methods
createConnectionFactory
public Object createConnectionFactory()
Throws ResourceException.
WebSphere MQ classes for Java does not currently support the
createConnectionFactory methods. This method throws a
javax.resource.NotSupportedException.
createConnectionFactory
public Object createConnectionFactory(ConnectionManager cxManager)
Throws ResourceException.
WebSphere MQ classes for Java does not currently support the
createConnectionFactory methods. This method throws a
javax.resource.NotSupportedException.
createManagedConnection
public ManagedConnection createManagedConnection
(javax.security.auth.Subject subject,
ConnectionRequestInfo cxRequestInfo)
Throws ResourceException.
Creates a new physical connection to a WebSphere MQ Queue Manager,
and returns a ManagedConnection object that represents this connection.
WebSphere MQ ignores the subject parameter.
equals
public boolean equals(Object other)
Throws ResourceException.
Returns the log writer for this ManagedConnectionFactory.
Chapter 9. The WebSphere MQ base Java classes and interfaces
183
ManagedConnectionFactory
WebSphere MQ classes for Java does not currently use the log writer. See
MQException.log on page 110 for more information about logging.
hashCode
public int hashCode()
Throws ResourceException.
Searches the supplied set of candidate ManagedConnections for an
appropriate ManagedConnection. Returns either null, or a suitable
ManagedConnection from the set that meets the criteria for connection.
setLogWriter
public void setLogWriter(java.io.PrintWriter out)
Throws ResourceException.
Sets the log writer for this ManagedConnectionFactory. When a
ManagedConnection is created, it inherits the log writer from its
ManagedConnectionFactory.
WebSphere MQ classes for Java does not currently use the log writer. See
MQException.log on page 110 for more information about logging.
184
ManagedConnectionMetaData
ManagedConnectionMetaData
public interface
javax.resource.spi.ManagedConnectionMetaData
Note: Normally, applications do not use this interface; it is intended for use by
implementations of ConnectionManager.
A ConnectionManager can use this interface to retrieve meta data that is related to
an underlying physical connection to a Queue Manager. An implementation of this
interface is returned from ManagedConnection.getMetaData(). For more details
about this interface, see the J2EE Connector Architecture specification (refer to
Suns Web site at http://java.sun.com).
Methods
getEISProductName
public String getEISProductName()
Throws ResourceException.
Returns IBM WebSphere MQ.
getMaxConnections
public int getMaxConnections()
Throws ResourceException.
Returns 0.
getProductVersion
public String getProductVersion()
Throws ResourceException.
Returns a string that describes the command level of the WebSphere MQ
Queue Manager to which the ManagedConnection is connected.
getUserName
public String getUserName()
Throws ResourceException.
If the ManagedConnection represents a Client connection to a Queue
Manager, this returns the user ID used for the connection. Otherwise, it
returns an empty string.
185
ManagedConnectionMetaData
186
|
|
|
|
|
|
. . . 189
. . . 189
. . . 190
. . . 190
. . . 191
. . . 191
. . . 192
. . . 192
. . . 193
. . . 193
. . . 195
. . . 195
. . . 196
. . . 196
. . . 197
. . . 197
. . . 198
. . . 198
. . . 198
. . . 198
. . . 199
. . . 199
. . . 199
. . . 199
. . . 200
. . . 201
203
203
203
203
204
204
204
205
207
207
209
209
209
209
210
210
210
212
213
214
214
214
214
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
215
215
215
216
216
217
219
219
219
220
222
223
223
225
225
229
230
233
234
236
237
237
239
240
241
187
LoggingMessageListenerFactory.java.
ASFClient2.java. . . . . . . .
TopicLoad.java . . . . . . . .
ASFClient3.java. . . . . . . .
ASFClient4.java. . . . . . . .
ASFClient5.java. . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
256
256
257
258
259
260
188
Constructors. . . . . .
Methods . . . . . . .
QueueSender . . . . . .
Methods . . . . . . .
QueueSession . . . . . .
Methods . . . . . . .
Session . . . . . . . .
Fields . . . . . . . .
Methods . . . . . . .
StreamMessage . . . . . .
Methods . . . . . . .
TemporaryQueue . . . . .
Methods . . . . . . .
TemporaryTopic . . . . .
WebSphere MQ constructor.
Methods . . . . . . .
TextMessage . . . . . . .
Methods . . . . . . .
Topic . . . . . . . . .
WebSphere MQ constructor.
Methods . . . . . . .
TopicConnection . . . . .
Methods . . . . . . .
TopicConnectionFactory . . .
WebSphere MQ constructor.
Methods . . . . . . .
TopicPublisher . . . . . .
Methods . . . . . . .
TopicRequestor . . . . . .
Constructors. . . . . .
Methods . . . . . . .
TopicSession. . . . . . .
WebSphere MQ constructor.
Methods . . . . . . .
TopicSubscriber. . . . . .
Methods . . . . . . .
XAConnection . . . . . .
XAConnectionFactory . . .
XAQueueConnection . . . .
Methods . . . . . . .
XAQueueConnectionFactory .
Methods . . . . . . .
XAQueueSession . . . . .
Methods . . . . . . .
XASession . . . . . . .
Methods . . . . . . .
XATopicConnection . . . .
Methods . . . . . . .
XATopicConnectionFactory . .
Methods . . . . . . .
XATopicSession. . . . . .
Methods . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
337
337
339
339
342
342
345
345
345
350
350
358
358
359
359
359
360
360
361
361
361
364
364
367
367
367
373
373
376
376
376
378
378
378
382
382
383
384
385
385
386
386
388
388
389
389
391
391
393
393
395
395
189
JMS model
The generic JMS interfaces are subclassed into more specific versions for
Point-to-Point and Publish/Subscribe behavior.
The point-to-point versions are:
v QueueConnection
v QueueSession
v QueueSender
v QueueReceiver
A key idea in JMS is that it is possible, and strongly recommended, to write
application programs that use only references to the interfaces in javax.jms. All
vendor-specific information is encapsulated in implementations of:
v QueueConnectionFactory
v TopicConnectionFactory
v Queue
v Topic
These are known as administered objects, that is, objects that can be built using a
vendor-supplied administration tool and can be stored in a JNDI namespace. A
JMS application can retrieve these objects from the namespace and use them
without needing to know which vendor provided the implementation.
Building a connection
Connections are not created directly, but are built using a connection factory.
Factory objects can be stored in a JNDI namespace, thus insulating the JMS
application from provider-specific information. Details of how to create and store
factory objects are in Chapter 5, Using the WebSphere MQ JMS administration
tool on page 39.
If you do not have a JNDI namespace available, see Creating factories at runtime
on page 191.
where:
icf
url
For more details about JNDI usage, see Suns JNDI documentation.
190
Building a connection
Note: Some combinations of the JNDI packages and LDAP service providers can
result in an LDAP error 84. To resolve the problem, insert the following line
before the call to InitialDirContext.
environment.put(Context.REFERRAL, "throw");
Once an initial context is obtained, objects are retrieved from the namespace by
using the lookup() method. The following code retrieves a
QueueConnectionFactory named ivtQCF from an LDAP-based namespace:
QueueConnectionFactory factory;
factory = (QueueConnectionFactory)ctx.lookup("cn=ivtQCF");
(You can omit the com.ibm.mq.jms. prefix if you import the com.ibm.mq.jms
package instead.)
A connection created from the above factory uses the Java bindings to connect to
the default queue manager on the local machine. The set methods shown in
Table 14 on page 192 can be used to customize the factory with WebSphere MQ
specific information.
The only way to create a TopicConnectionFactory object at runtime is to construct
it using the MQTopicConnectionFactory constructor. For example:
MQTopicConnectionFactory fact = new MQTopicConnectionFactory();
191
Building a connection
Description
setCCSID(int)
setChannel(String)
setHostName(String)
setPort(int)
setQueueManager(String)
setTemporaryModel(String)
setTransportType(int)
2. However, client transport is not supported on the z/OS & OS/390 platform.
192
Building a connection
String HOSTNAME = "machine1";
String QMGRNAME = "machine1.QM1";
String CHANNEL = "SYSTEM.DEF.SVRCONN";
factory = new MQQueueConnectionFactory();
factory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
factory.setQueueManager(QMGRNAME);
factory.setHostName(HOSTNAME);
factory.setChannel(CHANNEL);
Obtaining a session
Once a connection is made, use the createQueueSession method on the
QueueConnection to obtain a session.
The method takes two parameters:
1. A boolean that determines whether the session is transacted or
non-transacted.
2. A parameter that determines the acknowledge mode.
The simplest case is that of the non-transacted session with AUTO_ACKNOWLEDGE, as
shown in the following code fragment:
QueueSession session;
boolean transacted = false;
session = connection.createQueueSession(transacted,
Session.AUTO_ACKNOWLEDGE);
Note: A connection is thread safe, but sessions (and objects that are created from
them) are not. The recommended practice for multi-threaded applications is
to use a separate session for each thread.
Sending a message
Messages are sent using a MessageProducer. For point-to-point this is a
QueueSender that is created using the createSender method on QueueSession. A
QueueSender is normally created for a specific queue, so that all messages sent
using that sender are sent to the same destination. The destination is specified
using a Queue object. Queue objects can be either created at runtime, or built and
stored in a JNDI namespace.
Queue objects are retrieved from JNDI in the following way:
Queue ioQueue;
ioQueue = (Queue)ctx.lookup( qLookup );
193
Sending a message
public static final String QUEUE = "SYSTEM.DEFAULT.LOCAL.QUEUE" ;
.
.
.
ioQueue = session.createQueue( QUEUE );
v The second, and more powerful, form is based on uniform resource identifiers
(URI). This form allows you to specify remote queues (queues on a queue
manager other than the one to which you are connected). It also allows you to
set the other properties contained in a com.ibm.mq.jms.MQQueue object.
The URI for a queue begins with the sequence queue://, followed by the name
of the queue manager on which the queue resides. This is followed by a further
/, the name of the queue, and optionally, a list of name-value pairs that set
the remaining Queue properties. For example, the URI equivalent of the
previous example is:
ioQueue = session.createQueue("queue:///SYSTEM.DEFAULT.LOCAL.QUEUE");
Note that the name of the queue manager is omitted. This is interpreted as the
queue manager to which the owning QueueConnection is connected at the time
when the Queue object is used.
The following example connects to queue Q1 on queue manager HOST1.QM1, and
causes all messages to be sent as non-persistent and priority 5:
ioQueue = session.createQueue("queue://HOST1.QM1/Q1?persistence=1&priority=5");
Table 15 lists the names that can be used in the name-value part of the URI. A
disadvantage of this format is that it does not support symbolic names for the
values, so where appropriate, the table also indicates special values. Note that
these special values may be subject to change. (See Setting properties with the
set method on page 195 for an alternative method to set properties.)
Table 15. Property names for queue URIs
Property
Description
Values
expiry
priority
persistence
1=non-persistent, 2=persistent,
-1=QDEF, -2=APP
CCSID
targetClient
0=JMS, 1=MQ
encoding
QDEF
APP
- a special value that means the JMS application can control this property.
Once the Queue object is obtained (either using createQueue as above or from
JNDI), it must be passed into the createSender method to create a QueueSender:
QueueSender queueSender = session.createSender(ioQueue);
194
Sending a message
The resulting queueSender object is used to send messages by using the send
method:
queueSender.send(outMessage);
Table 16 shows the symbolic property values that are supplied with WebSphere
MQ JMS for use with the set methods.
Table 16. Symbolic values for queue properties
Property
Admin tool
keyword
Values
expiry
UNLIM
APP
JMSC.MQJMS_EXP_UNLIMITED
JMSC.MQJMS_EXP_APP
priority
APP
QDEF
JMSC.MQJMS_PRI_APP
JMSC.MQJMS_PRI_QDEF
persistence
APP
QDEF
PERS
NON
JMSC.MQJMS_PER_APP
JMSC.MQJMS_PER_QDEF
JMSC.MQJMS_PER_PER
JMSC.MQJMS_PER_NON
targetClient
JMS
MQ
JMSC.MQJMS_CLIENT_JMS_COMPLIANT
JMSC.MQJMS_CLIENT_NONJMS_MQ
encoding
Integer(N)
Integer(R)
Decimal(N)
Decimal(R)
Float(N)
Float(R)
Native
JMSC.MQJMS_ENCODING_INTEGER_NORMAL
JMSC.MQJMS_ENCODING_INTEGER_REVERSED
JMSC.MQJMS_ENCODING_DECIMAL_NORMAL
JMSC.MQJMS_ENCODING_DECIMAL_REVERSED
JMSC.MQJMS_ENCODING_FLOAT_IEEE_NORMAL
JMSC.MQJMS_ENCODING_FLOAT_IEEE_REVERSED
JMSC.MQJMS_ENCODING_NATIVE
Message types
JMS provides several message types, each of which embodies some knowledge of
its content. To avoid referencing the vendor-specific class names for the message
types, methods are provided on the Session object for message creation.
In the sample program, a text message is created in the following manner:
195
Sending a message
System.out.println( "Creating a TextMessage" );
TextMessage outMessage = session.createTextMessage();
System.out.println("Adding Text");
outMessage.setText(outString);
Receiving a message
Messages are received by using a QueueReceiver. This is created from a Session by
using the createReceiver() method. This method takes a Queue parameter that
defines where the messages are received from. See Sending a message on
page 193 for details of how to create a Queue object.
The sample program creates a receiver and reads back the test message with the
following code:
QueueReceiver queueReceiver = session.createReceiver(ioQueue);
Message inMessage = queueReceiver.receive(1000);
Message selectors
JMS provides a mechanism to select a subset of the messages on a queue so that
this subset is returned by a receive call. When creating a QueueReceiver, a string
196
Receiving a message
can be provided that contains an SQL (Structured Query Language) expression to
determine which messages to retrieve. The selector can refer to fields in the JMS
message header as well as fields in the message properties (these are effectively
application-defined header fields). Details of the header field names, as well as the
syntax for the SQL selector, are in Chapter 12, JMS messages on page 225.
The following example shows how to select for a user-defined property named
myProp:
queueReceiver = session.createReceiver(ioQueue, "myProp = blue");
Note: The JMS specification does not permit the selector associated with a receiver
to be changed. Once a receiver is created, the selector is fixed for the lifetime
of that receiver. This means that if you require different selectors, you must
create new receivers.
Asynchronous delivery
An alternative to making calls to QueueReceiver.receive() is to register a method
that is called automatically when a suitable message is available. The following
fragment illustrates the mechanism:
import javax.jms.*;
public class MyClass implements MessageListener
{
// The method that will be called by JMS when a message
// is available.
public void onMessage(Message message)
{
System.out.println("message is "+message);
// application specific processing here
.
.
.
}
}
.
.
.
// In Main program (possibly of some other class)
MyClass listener = new MyClass();
queueReceiver.setMessageListener(listener);
// main program can now continue with other application specific
// behavior.
Closing down
Garbage collection alone cannot release all WebSphere MQ resources in a timely
manner. This is especially true if the application needs to create many short-lived
JMS objects at the Session level or lower. It is therefore important to call the
close() methods of the various classes (QueueConnection, QueueSession,
QueueSender, and QueueReceiver) when the resources are no longer required.
197
Closing down
Handling errors
Any runtime errors in a JMS application are reported by exceptions. The majority
of methods in JMS throw JMSExceptions to indicate errors. It is good programming
practice to catch these exceptions and display them on a suitable output.
Unlike normal Java Exceptions, a JMSException may contain a further exception
embedded in it. For JMS, this can be a valuable way to pass important detail from
the underlying transport. In the case of WebSphere MQ JMS, when WebSphere MQ
raises an MQException, this exception is usually included as the embedded
exception in a JMSException.
The implementation of JMSException does not include the embedded exception in
the output of its toString() method. Therefore, it is necessary to check explicitly
for an embedded exception and print it out, as shown in the following fragment:
try {
.
. code which may throw a JMSException
.
} catch (JMSException je) {
System.err.println("caught "+je);
Exception e = je.getLinkedException();
if (e != null) {
System.err.println("linked exception: "+e);
}
}
Exception listener
For asynchronous message delivery, the application code cannot catch exceptions
raised by failures to receive messages. This is because the application code does
not make explicit calls to receive() methods. To cope with this situation, it is
possible to register an ExceptionListener, which is an instance of a class that
implements the onException() method. When a serious error occurs, this method
is called with the JMSException passed as its only parameter. Further details are in
Suns JMS documentation.
User Exits
WebSphere MQ JMS allows you to code and use implementations of the
WebSphere MQ base Java send, receive and security exits. For WebSphere MQ JMS,
you must ensure that your exit has a constructor that takes a single string
argument. See the description of exit-related set methods in Table 14 on page 192
and Property dependencies on page 51.
198
Using SSL
|
|
|
|
|
|
|
|
|
|
|
WebSphere MQ classes for Java uses Java Secure Socket Extension (JSSE) to handle
SSL encryption, and so requires a JSSE provider. J2SE v1.4 JVMs have a JSSE
provider built-in. Details of how to manage and store certificates can vary from
provider to provider. For information about this, refer to your JSSE providers
documentation.
|
|
This section assumes your JSSE provider is correctly installed and configured, and
suitable certificates have been installed and made available to your JSSE provider.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This can also be set from a program, using the setSSLCipherSuite() method on
MQConnectionFactory.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A JMS application can ensure that it has connected to the correct queue manager,
by specifying a distinguished name (DN) pattern. The connection will only succeed
if the queue manager presents a DN which matches the pattern. For more details
of the format of this pattern, refer to the WebSphere MQ Security book or the
WebSphere MQ Script (MQSC) Command Reference.
The DN is set using the SSLPEERNAME property of ConnectionFactory. For
example, the following JMSAdmin command sets the ConnectionFactory to expect
the queue manager to identify itself with a Common Name beginning QMGR.
with at least two Organizational Unit names, the first of which must be IBM and
the second WEBSPHERE:
ALTER QCF(my.qcf) SSLPEERNAME(CN=QMGR.*, OU=IBM, OU=WEBSPHERE)
Chapter 10. Writing WebSphere MQ JMS programs
199
Using SSL
|
|
|
|
|
Note that checking is case-insensitive, and that semicolons can be used in place of
the commas. This can also be set from a program, using the setSSLPeerName()
method on MQConnectionFactory. If this property is not set, no checking is
performed on the Distinguished Name supplied by the queue manager. This
property is ignored if no CipherSuite is set.
|
|
|
|
|
|
|
|
|
|
|
Note: To use a CertStore successfully with a CRL hosted on an LDAP server, make
sure that your Java Software Development Kit (SDK) is compatible with the
CRL. Some SDKs require that the CRL conforms to RFC 2587 which defines
a schema for LDAP v2. Most LDAP v3 servers use RFC 2256 instead.
|
|
|
|
|
|
|
If your LDAP server is not running on the default port of 389, the port can be
specified by appending a colon and the port number to the hostname. If the
certificate presented by the queue manager is present in the CRL hosted on
crl1.ibm.com, the connection will not complete. To avoid single-point-of-failure,
JMS allows multiple LDAP servers to be supplied, by supplying a space-delimited
list of ldap servers. For example:
|
|
|
When multiple LDAP servers are specified, JMS will try each one in turn until it
finds a server with which it can successfully verify the queue managers certificate.
Each server must contain identical information.
|
|
|
|
|
|
|
|
The certificate presented by the queue manager when a connection is being set up
is validated as follows:
|
|
|
|
|
|
|
|
|
|
|
|
3. If the attempt is successful, the server is searched for a match for the certificate.
a. If the certificate is found to be revoked, the search process is over and the
connection request will fail with reason code
MQRC_SSL_CERTIFICATE_REVOKED.
b. If the certificate is not found, the search process is over and the connection
is allowed to proceed.
4. If the attempt to contact the server is unsuccessful, the next CertStore object is
used to identify a CRL server and the process repeats from An attempt is
made to contact the CRL server.
200
Using SSL
|
|
|
If this was the last CertStore in the Collection, or if the Collection contains no
CertStore objects, the search process has failed and the connection request will
fail with reason code MQRC_SSL_CERT_STORE_ERROR.
The Collection object determines the order in which CertStores are used.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SSLSocketFactory
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Important: Do not assume that use of the SSL properties will ensure security when
the ConnectionFactory will be retrieved from a JNDI namespace which
is not itself secure. Specifically, the standard LDAP implementation of
JNDI is not secure; it is possible for an attacker to spoof the LDAP
server and hence fool a JMS application into connecting to the wrong
server without noticing. With suitable security arrangements in place,
other implementations of JNDI (such as the fscontext implementation)
are secure.
You might want to customize other aspects of the SSL connection for an
application. For example, you might want to initialize cryptographic hardware; or
change the KeyStore and TrustStore in use. To do this, the application should first
create a javax.net.ssl.SSLSocketFactory instance customized accordingly. Please refer
to your JSSE documentation for information on how to do this as the customizable
features vary from provider to provider. Once a suitable SSLSocketFactory has
been obtained, use the MQConnectionFactory.setSSLSocketFactory() method to
congure JMS to use the customized SSLSocketFactory.
201
Using SSL
202
Introduction
With publish/subscribe messaging, one message producer can send messages to
many message consumers at one time. The message producer need know nothing
about the consumers receiving its messages, it only needs to know about the
common destination. Similarly, the message consumers only need to know about
the common destination. This common destination is called a topic.
A message producer that sends messages to a topic is a publisher and a message
consumer that receives messages from a topic is a subscriber.
A message consumer will receive messages on all topics to which it has subscribed.
To receive messages from a topic, a message consumer must first subscribe to that
topic. All messages sent to a topic are forwarded to all the message consumers
subscribed to that topic at that time. Each consumer receives its own copy of each
message.
JMS clients can establish durable subscriptions that allow consumers to disconnect
and later reconnect and collect messages published while they were disconnected.
The connection between messages issued by publishers and the subscribers is
made, in WebSphere MQ, by the publish/subscribe broker. The broker (sometimes
referred to as the message broker) has a record of all the subscribers registered to a
topic. When a message is published to a topic, the broker manages the forwarding
of that message to the topics subscribers.
To run a WebSphere MQ JMS publish/subscribe application, you must be able to
connect to a message broker.
203
204
// JMS interfaces
// Used for JNDI lookup of
//
administered objects
import java.io.*;
import java.util.*;
// Java IO classes
// Java Util classes
class PubSubSample {
// using LDAP
String icf = "com.sun.jndi.ldap.LdapCtxFactory"; // initial context factory
String url = "ldap://server.company.com/o=company_us,c=us"; //url
private String tcfLookup = "cn=testTCF";
private String tLookup
= "cn=testT";
205
206
// JMS interfaces
// Used for JNDI lookup of
//
administered objects
Note: The icf and url variables need to be changed to suit your
installation and your JNDI service provider.
The properties required by JNDI initialization are in a hashtable, which is
passed to the InitialDirContext constructor. If this connection fails, an
exception is thrown to indicate that the administered objects required later
in the application are not available.
Now obtain a TopicConnectionFactory by using a lookup key that the
administrator has defined:
207
Create a TopicSession
This is created by using the TopicConnection. This method takes two
parameters; one to signify whether the session is transacted, and one to
specify the acknowledgement mode:
TopicSession sess = conn.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
Obtain a Topic
This object can be obtained from JNDI, for use with TopicPublishers and
TopicSubscribers that are created later. The following code retrieves a
Topic:
Topic topic = null;
try {
System.out.print( "Obtaining topic T from JNDI... " );
topic = (Topic)ctx.lookup( tLookup );
System.out.println( "Done!" );
}
catch ( NamingException nx ) {
System.out.println( "ERROR: " + nx );
System.exit(-1);
}
208
Publish messages
The TopicPublisher object, pub, is used to publish messages, rather like a
QueueSender is used in the point-to-point domain. The following fragment creates
a TextMessage by using the session, and then publishes the message:
// publish "hello world"
TextMessage hello = sess.createTextMessage();
hello.setText("Hello World");
pub.publish(hello);
hello.setText("Hello World 2");
pubA.publish(hello);
Receive subscriptions
Subscribers must be able to read the subscriptions that are delivered to them, as in
the following code:
// receive message
TextMessage m = (TextMessage) sub.receive();
System.out.println("Message Text = " + m.getText());
m = (TextMessage) subA.receive();
System.out.println("Message Text = " + m.getText());
This fragment of code performs a get-with-wait, which means that the receive
call will block until a message is available. Alternative versions of the receive call
are available (such as receiveNoWait). For details, see TopicSubscriber on
page 382.
209
Using topics
This section discusses the use of JMS Topic objects in WebSphere MQ classes for
Java Message Service applications.
Topic names
This section describes the use of topic names within WebSphere MQ classes for
Java Message Service.
Note: The JMS specification does not specify exact details about the use and
maintenance of topic hierarchies. Therefore, this area can vary from one
provider to the next.
210
Using topics
Topic names in WebSphere MQ JMS are arranged in a tree-like hierarchy, an
example of which is shown in Figure 3.
Sport
Football
Rugby
Arsenal
Spurs
Results
Tennis
Results
Signings
Figure 3. WebSphere MQ classes for Java Message Service topic name hierarchy
In a topic name, levels in the tree are separated by the / character. This means
that the Signings node in Figure 3 is identified by the topic name:
Sport/Football/Spurs/Signings
A powerful feature of the topic system in WebSphere MQ classes for Java Message
Service is the use of wildcards. These allow subscribers to subscribe to more than
one topic at a time. Different brokers use different wildcard characters and
different rules for their substitution. Use the broker version property of the topic
(BROKERVER) to define which type of wildcards apply.
Note: The broker version of a topic must match the broker version of the topic
connection factory you are using.
Broker Version 1 wildcards
The * wildcard matches zero or more characters, while the ? wildcard
matches a single character.
If a subscriber subscribes to the topic represented by the following topic
name:
Sport/Football/*/Results
211
Using topics
v Sport/Football/Arsenal/Results
v Sport/Football/Spurs/Results
v Sport/Football/Spurs/Signings
Broker Version 2 wildcards
The # wildcard matches multiple levels in a topic, the + wildcard
matches a single level.
These wildcards can only be used to stand for complete levels within a
topic; that is they can only be preceded by / or by start-of-string, and
they can only be followed by / or by end-of-string.
If a subscriber subscribes to the topic represented by the following topic
name:
Sport/Football/+/Results
works with broker version 1, there is no equivalent for broker version 2 which
does not support single character substitutions.
There is no need to administer the topic hierarchies that you use on the broker-side
of your system explicitly. When the first publisher or subscriber on a given topic
comes into existence, the broker automatically creates the state of the topics
currently being published on, and subscribed to.
Note: A publisher cannot publish on a topic whose name contains wildcards.
212
Using topics
The constructor takes one argument, which should be a uniform resource
identifier (URI). For WebSphere MQ classes for Java Message Service
Topics, this should be of the form:
topic://TopicName[?property=value[&property=value]*]
For further details on URIs and the permitted name-value pairs, see
Sending a message on page 193.
The following code creates a topic for non-persistent, priority 5 messages:
// Create a Topic using the one-argument MQTopic constructor
String tSpec = "Sport/Football/Spurs/Results?persistence=1&priority=5";
Topic rtTopic = new MQTopic( "topic://" + tSpec );
|
|
|
Subscriber options
There are a number of different ways to use JMS subscribers. This section describes
some examples of their use.
JMS provides two types of subscribers:
Non-durable subscribers
These subscribers receive messages on their chosen topic, only if the
messages are published while the subscriber is active.
Chapter 11. Programming publish/subscribe applications
213
Subscriber options
Durable subscribers
These subscribers receive all the messages published on a topic, including
those that are published while the subscriber is inactive.
214
Subscriber options
Default configuration
The default configuration uses the following shared subscription queues:
v SYSTEM.JMS.ND.SUBSCRIBER.QUEUE for non-durable subscriptions
v SYSTEM.JMS.D.SUBSCRIBER.QUEUE for durable subscriptions
These are created for you when you run the MQJMS_PSQ.MQSC script.
Chapter 11. Programming publish/subscribe applications
215
Subscriber options
If required, you can specify alternative physical queues. You can also change the
configuration to use the multiple queue approach.
216
Subscriber options
// Create a durable subscriber using our earlier Topic
TopicSubscriber sub = new session.createDurableSubscriber
(sportsTopic, "D_SUB_SPORT_001");
For durable subscriptions, the queue name you provide should start with the
following characters:
SYSTEM.JMS.D.
To select a shared queue approach, specify an explicit queue name, where the
named queue is the one to use for the shared queue. The queue that you specify
must already physically exist before you create the subscription.
To select the multiple queue approach, specify a queue name that ends with the *
character. Subsequently, each subscriber that is created with this queue name
creates an appropriate dynamic queue, for exclusive use by that particular
subscriber. MQ JMS uses its own internal model queue to create such queues.
Therefore, with the multiple queue approach, all required queues are created
dynamically.
When you use the multiple queue approach, you cannot specify an explicit queue
name. However, you can specify the queue prefix. This enables you to create
different subscriber queue domains. For example, you could use:
SYSTEM.JMS.D.MYDOMAIN.*
The characters that precede the * character are used as the prefix, so that all
dynamic queues that are associated with this subscription will have queue names
that start with SYSTEM.JMS.D.MYDOMAIN.
Note that you can not change the queue used by a durable subscriber. To do so, for
example to move from the multiple queue approach to the single queue approach,
you should first delete the old subscriber (using the unsubscribe() method) and
create the subscription again from new. This will remove any unconsumed
messages on the durable subscription.
Subscription stores
There is no subscription store with a direct connection to WebSphere MQ Event
Broker.
WebSphere MQ JMS maintains a persistent store of subscription information, used
to resume durable subscriptions and cleanup after failed non-durable subscribers.
Before WebSphere MQ JMS 5.2.1, this information was stored using messages on
system queues on the applications local queue manager; from WebSphere MQ JMS
5.2.1 this information can be managed by the publish/subscribe broker. This new
subscription store requires recent levels of both queue manager and
publish/subscribe broker. It is designed to provide improved resilience.
Please see the readme provided with WebSphere MQ JMS for information about
suitable levels of queue manager and broker.
The choice of subscription store is based on the SUBSTORE property of the
TopicConnectionFactory. This takes one of three values, QUEUE, BROKER or
MIGRATE.
SUBSTORE(QUEUE)
Subscription information is stored on SYSTEM.JMS.ADMIN.QUEUE and
SYSTEM.JMS.PS.STATUS.QUEUE on the local queue manager.
Chapter 11. Programming publish/subscribe applications
217
Subscriber options
WebSphere MQ JMS maintains an extra connection for a long-running
transaction used to detect failed subscribers. There is a connection to each
queue manager in use. In a busy system, this may cause the queue
manager logs to fill up and this will result in errors from both the queue
manager and its applications.
If you experience these problems, the system administrator can add extra
log files or datasets to the queue manager. Alternatively, the
STATREFRESHINT property on the TopicConnectionFactory can be
reduced. This will cause the long-running transaction to be refreshed more
frequently, allowing the logs to reset themselves.
After a non-durable subscriber has failed, information is left on the two
SYSTEM.JMS queues which allows a later JMS application to cleanup after
the failed subscriber. See Subscriber cleanup utility on page 220 for more
information.
After failure of a non-durable subscriber, messages will continue to be
delivered to the subscriber until a later JMS application is executed.
SUBSTORE(QUEUE) is provided for compatibility with versions of
WebSphere MQ JMS before 5.2.1.
SUBSTORE(BROKER)
Subscription information is stored by the publish/subscribe broker used by
the application. This option requires recent levels of queue manager and
publish/subscribe broker. Please see the readme provided with WebSphere
MQ JMS for information about suitable levels of Queue Manager and
broker.
When a non-durable subscriber fails, the subscription is deregistered from
the broker as soon as possible. The broker adds a response to this
deregistration onto the SYSTEM.JMS.REPORT.QUEUE, which is used to
cleanup after the failed subscriber. With SUBSTORE(BROKER), a separate
cleanup thread is run regularly in the background of each JMS
publish/subscribe application.
Cleanup is run once every 10 minutes by default, but you can change this
using the CLEANUPINT property on the TopicConnectionFactory. The
actions performed by cleanup can be customised using the CLEANUP
property on the TopicConnectionFactory.
See Subscriber cleanup utility on page 220 for more information about
the different behaviours of cleanup with SUBSTORE(BROKER).
SUBSTORE(MIGRATE)
MIGRATE is the default value for SUBSTORE.
This option dynamically selects the Queue-based or broker-based
subscription store based on the levels of queue manager and
publish/subscribe broker installed. If both queue manager and broker are
capable of supporting SUBSTORE(BROKER) then this will behave as
SUBSTORE(BROKER); otherwise it will behave as SUBSTORE(QUEUE).
Additionally, SUBSTORE(MIGRATE) will transfer durable subscription
information from the Queue-based subscription store to the broker-based
store.
This provides an easy migration path from older versions of WebSphere
MQ JMS, WebSphere MQ and publish/subscribe broker. This migration
occurs the first time the durable subscription is opened when both Queue
Manager and broker are capable of supporting the broker-based
218
Subscriber options
subscription store. Only information relating to the subscription being
opened is migrated; information relating to other subscriptions is left in the
Queue-based subscription store.
219
Publish/subscribe problems
TopicConnection results in calls to close on each of the TopicSessions it created.
This in turn results in calls to close on all TopicSubscribers and TopicPublishers
the sessions created.
Therefore, to ensure the proper release of external resources, it is important to call
connection.close() for each of the connections that an application creates.
There are some circumstances where this close procedure may not complete.
These include:
v Loss of a WebSphere MQ client connection
v Unexpected application termination
In these circumstances, the close() is not called, and external resources remain
open on the terminated applications behalf. The main consequences of this are:
Broker state inconsistency
The WebSphere MQ Message Broker may well contain registration
information for subscribers and publishers that no longer exist. This means
that the broker may continue forwarding messages to subscribers that will
never receive them.
Subscriber messages and queues remain
Part of the subscriber deregistration procedure is the removal of subscriber
messages. If appropriate, the underlying WebSphere MQ queue that was
used to receive subscriptions is also removed. If normal closure has not
occurred, these messages and queues remain. If there is broker state
inconsistency, the queues continue to fill up with messages that will never
be read.
Additionally, if the broker resides on a queue manager other than the applications
local queue manager, correct operation of WebSphere MQ JMS depends on the
communication channels between the two queue managers. If these channels fail
for any reason, problems such as the above can occur until the channels restart.
When diagnosing problems relating to channels, be careful not to lose WebSphere
MQ JMS control messages on the transmission queue.
220
Publish/subscribe problems
If all the TopicConnections on a given queue manager become closed,
when the next TopicConnection initializes for that queue manager, the
utility runs again.
The Cleanup utility uses information found on the
SYSTEM.JMS.ADMIN.QUEUE and SYSTEM.JMS.PS.STATUS.QUEUE to
detect previously failed subscribers. If any are found, it cleans up
associated resources by deregistering the subscriber from the broker, and
cleaning up any unconsumed messages or temporary queues associated
with the subscription.
Subscriber Cleanup with SUBSTORE(BROKER)
With the broker-based subscription store, Cleanup runs regularly on a
background thread while there is an open TopicConnection to a particular
physical queue manager. One instance of the Cleanup thread is created for
each physical queue manager to which a TopicConnection exists within the
JVM.
The Cleanup utility uses information found on the
SYSTEM.JMS.REPORT.QUEUE (typically responses from the
publish/subscribe broker) to remove unconsumed messages and temporary
queues associated with a failed subscriber. It can be a few seconds after the
subscriber fails before the Cleanup routine is able to remove the messages
and queues.
Two properties on the TopicConnectionFactory control behavior of this
Cleanup thread: CLEANUP and CLEANUPINT. CLEANUPINT determines
how often (in milliseconds) Cleanup is executed against any given queue
manager. CLEANUP takes one of four possible values:
CLEANUP(SAFE)
This is the default value.
The Cleanup thread will attempt to remove unconsumed
subscription messages, or temporary queues, for failed
subscriptions. This mode of Cleanup will not interfere with the
operation of other JMS applications.
CLEANUP(STRONG)
The Cleanup thread will perform as CLEANUP(SAFE), but will
also clear the SYSTEM.JMS.REPORT.QUEUE of any unrecognised
messages.
This mode of Cleanup may interfere with the operation of JMS
applications running with later versions of WebSphere MQ JMS.
Hence, it is important that if multiple JMS applications are using
the same queue manager, but using different versions of
WebSphere MQ JMS, only clients using the most recent version of
WebSphere MQ JMS use this option.
CLEANUP(NONE)
In this special mode, no Cleanup is performed; and no Cleanup
thread exists. Additionally, if the application is using the
single-queue approach, unconsumed messages can be left on the
queue.
This option can be useful if the application is distant from the
Queue Manager, and especially if it only publishes rather than
subscribes. However, some application should perform Cleanup on
the queue manager to deal with any unconsumed messages - this
221
Publish/subscribe problems
could be a JMS application with CLEANUP(SAFE) or
CLEANUP(STRONG), or the manual Cleanup utility described in
Manual cleanup.
CLEANUP(ASPROP)
The style of Cleanup to use is determined by the system property
com.ibm.mq.jms.cleanup, which is queried at JVM startup.
This property can be set on the java command-line using the -D
option, and should be set to NONE, SAFE or STRONG. Any other
value causes an exception. If not set, the property defaults to SAFE.
Manual cleanup
If you use the broker-based subscription store, Cleanup can be operated manually
from the command-line. The syntax for bindings attach is:
Cleanup [-m <qmgr>] [-r <interval>]
[SAFE | STRONG | FORCE | NONDUR] [-t]
Where:
v qmgr, hostname, port and channel determine connection settings for the queue
manager to clean up
v -r sets the interval between executions of Cleanup, in minutes. If not set,
Cleanup will be performed once.
v -t enables tracing, to the mqjms.trc file
v SAFE, STRONG, FORCE and NONDUR set the Cleanup level, as follows:
SAFE and STRONG Cleanup behave like the CLEANUP(SAFE) and
CLEANUP(STRONG) options discussed in Subscriber cleanup utility on
page 220.
222
Publish/subscribe problems
FORCE Cleanup behaves like STRONG Cleanup. However, while STRONG
Cleanup will leave messages on the SYSTEM.JMS.REPORT.QUEUE which
could not be processed, FORCE Cleanup will remove all messages even if it
encounters an error during processing.
This is a dangerous option which can leave an inconsistent state between the
queue manager and the broker. It can not be run while any WebSphere MQ
JMS publish/subscribe application is running against the queue manager;
doing so will cause the Cleanup utility to abort.
NONDUR behaves like FORCE Cleanup.
After clearing the SYSTEM.JMS.REPORT.QUEUE, it attempts to remove any
remaining unconsumed messages sent to non-durable subscribers. If the
queue managers command server is running, on any queue beginning
SYSTEM.JMS.ND.* messages will be cleared and the queue itself may be
deleted. Otherwise, only SYSTEM.JMS.ND.SUBSCRIBER.QUEUE and
SYSTEM.JMS.ND.CC.SUBSCRIBER.QUEUE will be cleared of messages.
where:
223
Publish/subscribe problems
-m queueManager
The name of the queue manager to use
-clear
224
All messages support the same set of header fields. Header fields
contain values that are used by both clients and providers to
identify and route messages.
Properties
Body
Map
Text
Object
Bytes
The JMSCorrelationID header field is used to link one message with another. It
typically links a reply message with its requesting message. JMSCorrelationID can
hold a provider-specific message ID, an application-specific String, or a
provider-native byte[] value.
Message selectors
A Message contains a built-in facility to support application-defined property
values. In effect, this provides a mechanism to add application-specific header
fields to a message. Properties allow an application, via message selectors, to have
a JMS provider select or filter messages on its behalf, using application-specific
criteria. Application-defined properties must obey the following rules:
v Property names must obey the rules for a message selector identifier.
v Property values can be boolean, byte, short, int, long, float, double, and string.
v The following name prefixes are reserved: JMSX, JMS_.
Property values are set before sending a message. When a client receives a
message, the message properties are read-only. If a client attempts to set properties
at this point, a MessageNotWriteableException is thrown. If clearProperties is
called, the properties can now be both read from, and written to.
A property value may duplicate a value in a messages body, or it may not. JMS
does not define a policy for what should or should not be made into a property.
Copyright IBM Corp. 1997, 2002
225
Message selectors
However, application developers should note that JMS providers will probably
handle data in a messages body more efficiently than data in a messages
properties. For best performance, applications should only use message properties
when they need to customize a messages header. The primary reason for doing
this is to support customized message selection.
A JMS message selector allows a client to specify the messages that it is interested
in by using the message header. Only messages whose headers match the selector
are delivered.
Message selectors cannot reference message body values.
A message selector matches a message when the selector evaluates to true when
the messages header field and property values are substituted for their
corresponding identifiers in the selector.
A message selector is a String, whose syntax is based on a subset of the SQL92
conditional expression syntax. The order in which a message selector is evaluated
is from left to right within a precedence level. You can use parentheses to change
this order. Predefined selector literals and operator names are written here in
upper case; however, they are not case-sensitive.
A selector can contain:
v Literals
A string literal is enclosed in single quotes. A doubled single quote represents
a single quote. Examples are literal and literals. Like Java string literals,
these use the Unicode character encoding.
An exact numeric literal is a numeric value without a decimal point, such as
57, -957, +62. Numbers in the range of Java long are supported.
An approximate numeric literal is a numeric value in scientific notation, such
as 7E3 or -57.9E2, or a numeric value with a decimal, such as 7., -95.7, or +6.2.
Numbers in the range of Java double are supported.
The boolean literals TRUE and FALSE.
v Identifiers:
An identifier is an unlimited length sequence of Java letters and Java digits,
the first of which must be a Java letter. A letter is any character for which the
method Character.isJavaLetter returns true. This includes _ and $. A letter
or digit is any character for which the method Character.isJavaLetterOrDigit
returns true.
Identifiers cannot be the names NULL, TRUE, or FALSE.
Identifiers cannot be NOT, AND, OR, BETWEEN, LIKE, IN, and IS.
Identifiers are either header field references or property references.
Identifiers are case-sensitive.
Message header field references are restricted to:
- JMSDeliveryMode
-
JMSPriority
JMSMessageID
JMSTimestamp
JMSCorrelationID
- JMSType
226
Message selectors
JMSMessageID, JMSTimestamp, JMSCorrelationID, and JMSType values may
be null, and if so, are treated as a NULL value.
Any name beginning with JMSX is a JMS-defined property name.
Any name beginning with JMS_ is a provider-specific property name.
Any name that does not begin with JMS is an application-specific property
name. If there is a reference to a property that does not exist in a message, its
value is NULL. If it does exist, its value is the corresponding property value.
v White space is the same as it is defined for Java: space, horizontal tab, form
feed, and line terminator.
v Expressions:
v
v
v
+, - unary.
*, /, multiplication, and division.
+, -, addition, and subtraction.
Arithmetic operations on a NULL value are not supported. If they are
attempted, the complete selector is always false.
Arithmetic operations must use Java numeric promotion.
v arithmetic-expr1 [NOT] BETWEEN arithmetic-expr2 and arithmetic-expr3
comparison operator:
age BETWEEN 15 and 19 is equivalent to age >= 15 AND age <= 19.
age NOT BETWEEN 15 and 19 is equivalent to age < 15 OR age > 19.
If any of the exprs of a BETWEEN operation are NULL, the value of the
operation is false. If any of the exprs of a NOT BETWEEN operation are
NULL, the value of the operation is true.
v identifier [NOT] IN (string-literal1, string-literal2,...) comparison operator where
identifier has a String or NULL value.
Country IN ( UK, US, France) is true for UK and false for Peru. It is
equivalent to the expression (Country = UK) OR (Country = US) OR
(Country = France).
Country NOT IN ( UK, US, France) is false for UK and true for Peru. It
is equivalent to the expression NOT ((Country = UK) OR (Country = US)
OR (Country = France)).
227
Message selectors
If the identifier of an IN or NOT IN operation is NULL, the value of the
operation is unknown.
v identifier [NOT] LIKE pattern-value [ESCAPE escape-character] comparison
operator, where identifier has a String value. pattern-value is a string literal,
where _ stands for any single character and % stands for any sequence of
characters (including the empty sequence). All other characters stand for
themselves. The optional escape-character is a single character string literal,
whose character is used to escape the special meaning of the _ and % in
pattern-value.
phone LIKE 12%3 is true for 123 12993 and false for 1234.
word LIKE l_se is true for lose and false for loose.
underscored LIKE \_% ESCAPE \ is true for _foo and false for bar.
phone NOT LIKE 12%3 is false for 123 12993 and true for 1234.
If the identifier of a LIKE or NOT LIKE operation is NULL, the value of the
operation is unknown.
v identifier IS NULL comparison operator tests for a null header field value, or a
missing property value.
prop_name IS NULL.
v identifier IS NOT NULL comparison operator tests for the existence of a
non-null header field value or a property value.
prop_name IS NOT NULL.
The following message selector selects messages with a message type of car, color
of blue, and weight greater than 2500 lbs:
"JMSType = car AND color = blue AND weight > 2500"
228
Mapping
MQMD
JMS Client
Mapping
JMS Message
Data
Header
Header
RFH2
Properties
Data
Copying
Other Data
Properties
Copying
Data
Figure 4. How messages are transformed between JMS and WebSphere MQ using the
MQRFH2 header
229
230
Meaning
1200
1208
13488
17584
UCS2 open-ended
UTF8
UCS2 2.0 subset
UCS2 2.1 subset (includes Euro symbol)
Variable Portion
The variable portion follows the fixed portion. The variable portion
contains a variable number of MQRFH2 Folders. Each folder contains a
variable number of elements or properties. Folders group together related
properties. The MQRFH2 headers created by JMS can contain up to three
folders:
The <mcd> folder
This contains properties that describe the shape or format of
the message. For example the Msd property identifies the message
as being Text, Bytes, Stream. Map, Object, or Null. This folder is
always present in a JMS MQRFH2.
The <jms> folder
This is used to transport JMS header fields, and JMSX properties
that cannot be fully expressed in the MQMD. This folder is always
present in a JMS MQRFH2.
The <usr> folder
This is used to transport any application-defined properties
associated with the message. This folder is only present if the
application has set some application-defined properties.
Table 18 shows a full list of property names.
Table 18. MQRFH2 folders and properties used by JMS
JMS Field Name
Java type
MQRFH2
Folder name
JMSDestination
Destination
jms
Dst
string
JMSExpiration
long
jms
Exp
i8
JMSPriority
int
jms
Pri
i4
JMSDeliveryMode
int
jms
Dlv
i4
JMSCorrelationID
String
jms
Cid
string
JMSReplyTo
Destination
jms
Rto
string
JMSTimestamp
long
jms
Tms
i8
JMSType
String
mcd
string
JMSXGroupID
String
jms
Gid
string
JMSXGroupSeq
int
jms
Seq
i4
231
Java type
MQRFH2
Folder name
Any
usr
xxx
any
mcd
Msd
jms_none
jms_text
jms_bytes
jms_map
jms_stream
jms_object
tripletn </foldername>
232
Datatype
value
Definition
string
boolean
Definition
bin.hex
i1
A number, expressed using digits 0..9, with optional sign (no fractions or
exponent). Must lie in the range -128 to 127 inclusive
i2
A number, expressed using digits 0..9, with optional sign (no fractions or
exponent). Must lie in the range -32768 to 32767 inclusive
i4
A number, expressed using digits 0..9, with optional sign (no fractions or
exponent). Must lie in the range -2147483648 to 2147483647 inclusive
i8
A number, expressed using digits 0..9, with optional sign (no fractions or
exponent). Must lie in the range -9223372036854775808 to
92233720368547750807 inclusive
int
A number, expressed using digits 0..9, with optional sign (no fractions or
exponent). Must lie in the same range as i8. This can be used in place of
one of the i* types if the sender does not wish to associate a particular
precision with the property
r4
r8
A string value may contain spaces. You must use the following
escape sequences in a string value:
& for the & character
< for the < character
You can use the following escape sequences, but they are not
required:
> for the > character
' for the character
" for the " character
Java
type
MQMD field
C type
JMSDeliveryMode
int
Persistence
MQLONG
JMSExpiration
long
Expiry
MQLONG
JMSPriority
int
Priority
MQLONG
JMSMessageID
String
MessageID
MQBYTE24
JMSTimestamp
long
PutDate
PutTime
MQCHAR8
MQCHAR8
JMSCorrelationID
String
CorrelId
MQBYTE24
233
Java
type
MQMD field
C type
JMSXUserID
String
UserIdentifier
MQCHAR12
JMSXAppID
String
PutApplName
MQCHAR28
JMSXDeliveryCount
int
BackoutCount
MQLONG
JMSXGroupID
String
GroupId
MQBYTE24
JMSXGroupSeq
int
MsgSeqNumber
MQLONG
Java
type
MQMD field
C type
JMS_IBM_Report_Exception
int
Report
MQLONG
JMS_IBM_Report_Expiration
int
Report
MQLONG
JMS_IBM_Report_COA
int
Report
MQLONG
JMS_IBM_Report_COD
int
Report
MQLONG
JMS_IBM_Report_PAN
int
Report
MQLONG
JMS_IBM_Report_NAN
int
Report
MQLONG
JMS_IBM_Report_Pass_Msg_ID
int
Report
MQLONG
JMS_IBM_Report_Pass_Correl_ID
int
Report
MQLONG
JMS_IBM_Report_Discard_Msg
int
Report
MQLONG
JMS_IBM_MsgType
int
MsgType
MQLONG
JMS_IBM_Feedback
int
Feedback
MQLONG
JMS_IBM_Format
String
Format
MQCHAR8
JMS_IBM_PutApplType
int
PutApplType
MQLONG
JMS_IBM_Encoding
int
Encoding
MQLONG
JMS_IBM_Character_Set
String
CodedCharacterSetId
MQLONG
JMS_IBM_PutDate
String
PutDate
MQCHAR8
JMS_IBM_PutTime
String
PutTime
MQCHAR8
JMS_IBM_Last_Msg_In_Group
boolean MsgFlags
MQLONG
234
JMSDestination
Header
Set by
MQRFH2
Send Method
JMSDeliveryMode
Persistence
MQRFH2
Send Method
JMSExpiration
Expiry
MQRFH2
Send Method
JMSPriority
Priority
MQRFH2
Send Method
JMSMessageID
MessageID
Send Method
JMSTimestamp
PutDate/PutTime
Send Method
JMSCorrelationID
CorrelId
MQRFH2
Message Object
JMSReplyTo
ReplyToQ/ReplyToQMgr
MQRFH2
Message Object
MQRFH2
Message Object
JMSType
JMSRedelivered
Receive-only
Header
Set by
JMSXUserID
UserIdentifier
Send Method
JMSXAppID
PutApplName
Send Method
JMSXDeliveryCount
Receive-only
JMSXGroupID
GroupId
MQRFH2
Message Object
JMSXGroupSeq
MsgSeqNumber
MQRFH2
Message Object
Header
Set by
JMS_IBM_Report_Exception
Report
Message Object
JMS_IBM_Report_Expiration
Report
Message Object
JMS_IBM_Report_COA/COD
Report
Message Object
JMS_IBM_Report_NAN/PAN
Report
Message Object
JMS_IBM_Report_Pass_Msg_ID
Report
Message Object
JMS_IBM_Report_Pass_Correl_ID
Report
Message Object
JMS_IBM_Report_Discard_Msg
Report
Message Object
JMS_IBM_MsgType
MsgType
Message Object
JMS_IBM_Feedback
Feedback
Message Object
JMS_IBM_Format
Format
Message Object
JMS_IBM_PutApplType
PutApplType
Send Method
JMS_IBM_Encoding
Encoding
Message Object
JMS_IBM_Character_Set
CodedCharacterSetId
Message Object
JMS_IBM_PutDate
PutDate
Send Method
JMS_IBM_PutTime
PutTime
Send Method
235
JMS_IBM_Last_Msg_In_Group
MsgFlags
Header
Set by
Message Object
|
|
If the send() method sets a time to live that is less than 214748364.7 seconds
(about 7 years), the time to live is stored in MQMD. Expiry and the expiration
time (in milliseconds) is encoded as an i8 value in the MQRFH2.
If the send() method sets a time to live greater than 214748364.7 seconds,
MQMD.Expiry is set to MQEI_UNLIMITED. The true expiration time in
milliseconds is encoded as an i8 value in the MQRFH2.
v JMSPriority to MQMD Priority: Directly map JMSPriority value (0-9) onto
MQMD priority value (0-9). If JMSPriority is set to a non-default value, the
priority level is also encoded in the MQRFH2.
v JMSMessageID from MQMD MessageID: All messages sent from JMS have
unique message identifiers assigned by WebSphere MQ. The value assigned is
returned in the MQMD messageId field after the MQPUT call, and is passed
back to the application in the JMSMessageID field. The WebSphere MQ
messageId is a 24-byte binary value, whereas the JMSMessageID is a String. The
JMSMessageID is composed of the binary messageId value converted to a
sequence of 48 hexadecimal characters, prefixed with the characters ID:. JMS
provides a hint that can be set to disable the production of message identifiers.
This hint is ignored, and a unique identifier is assigned in all cases. Any value
that is set into the JMSMessageId field before a send() is overwritten.
236
237
v
v
v
v
v
238
JMS_IBM_Report_Discard_Msg
MQRO_DISCARD_MSG
JMS_IBM_MsgType to MQMD MsgType: Value maps directly onto MQMD
MsgType. If the application has not set an explicit value of JMS_IBM_MsgType,
then a default value is used. This default value is determined as follows:
If JMSReplyTo is set to a WebSphere MQ queue destination, MSGType is set
to the value MQMT_REQUEST
If JMSReplyTo is not set, or is set to anything other than a WebSphere MQ
queue destination, MsgType is set to the value MQMT_DATAGRAM
JMS_IBM_Feedback to MQMD Feedback: Value maps directly onto MQMD
Feedback.
JMS_IBM_Format to MQMD Format: Value maps directly onto MQMD Format.
JMS_IBM_Encoding to MQMD Encoding: If set, this property overrides the
numeric encoding of the Destination Queue or Topic.
JMS_IBM_Character_Set to MQMD CodedCharacterSetId: If set, this property
overrides the coded character set property of the Destination Queue or Topic.
JMS_IBM_PutDate from MQMD PutDate: The value of this property is set,
during send, directly from the PutDate field in the MQMD. Any value that is set
into the JMS_IBM_PutDate property before a send is overwritten. This field is a
String of eight characters, in the WebSphere MQ Date format of YYYYMMDD.
This property can be used in conjunction with the JMS_IBM_PutTime property
to determine the time the message was put according to the queue manager.
JMS_IBM_PutTime from MQMD PutTime: The value of this property is set,
during send, directly from the PutTime field in the MQMD. Any value that is set
JMSDestination
JMSDeliveryMode
jms.Dst
1
jms.Dlv1
Persistence
JMSExpiration
jms.Exp
JMSPriority
Priority
JMSMessageID
MessageID
JMSTimestamp
PutDate1
PutTime1
jms.Tms1
JMSCorrelationID
CorrelId1
jms.Cid1
JMSReplyTo
ReplyToQ1
ReplyToQMgr1
jms.Rto1
JMSType
JMSRedelivered
|
|
|
MQRFH2 field
retrieved from
mcd.Type, mcd.Set,
mcd.Fmt
BackoutCount
Notes:
1. For properties that can have values retrieved from the MQRFH2 or the MQMD, if both
are available, the setting in the MQRFH2 is used.
Table 27. Incoming message property mapping
JMS property name
MQRFH2 field
retrieved from
JMSXUserID
UserIdentifier
JMSXAppID
PutApplName
JMSXDeliveryCount
BackoutCount
JMSXGroupID
GroupId1
jms.Gid1
JMSXGroupSeq
MsgSeqNumber1
jms.Seq1
239
|
|
|
MQRFH2 field
retrieved from
Notes:
1. For properties that can have values retrieved from the MQRFH2 or the MQMD, if both
are available, the setting in the MQRFH2 is used.
Table 28. Incoming message provider specific JMS property mapping
JMS property name
JMS_IBM_Report_Exception
Report
JMS_IBM_Report_Expiration
Report
JMS_IBM_Report_COA
Report
JMS_IBM_Report_COD
Report
JMS_IBM_Report_PAN
Report
JMS_IBM_Report_NAN
Report
JMS_IBM_Report_ Pass_Msg_ID
Report
MQRFH2 field
retrieved from
JMS_IBM_Report_Pass_Correl_ID Report
JMS_IBM_Report_Discard_Msg
Report
JMS_IBM_MsgType
MsgType
JMS_IBM_Feedback
Feedback
JMS_IBM_Format
Format
JMS_IBM_PutApplType
JMS_IBM_Encoding
PutApplType
JMS_IBM_Character_Set
Encoding
1
CodedCharacterSetId
JMS_IBM_PutDate
PutDate
JMS_IBM_PutTime
PutTime
JMS_IBM_Last_Msg_In_Group
MsgFlags
240
Header
Properties
Data
JMS Client
WebSphere MQ
Message
JMS Message
Mapping
Mapping
Copying
JMS Message
Mapping
MQMD
Data
Mapping
Copying
Header
Properties
Data
Message body
This section discusses the encoding of the message body itself. The encoding
depends on the type of JMS message:
ObjectMessage
is an object serialized by the Java Runtime in the normal way.
TextMessage
is an encoded string. For an outgoing message, the string is encoded in the
character set given by the Destination object. This defaults to UTF8
encoding (the UTF8 encoding starts with the first character of the message
- there is no length field at the start). It is, however, possible to specify any
other character set supported by WebSphere MQ Java. Such character sets
are used mainly when you send a message to a non-JMS application.
If the character set is a double-byte set (including UTF16), the Destination
objects integer encoding specification determines the order of the bytes.
An incoming message is interpreted using the character set and encoding
that are specified in the message itself. These specifications are in the
rightmost WebSphere MQ header (or MQMD if there are no headers). For
JMS messages, the rightmost header will usually be the MQRFH2.
BytesMessage
is, by default, a sequence of bytes as defined by the JMS 1.0.2 specification,
and associated Java documentation.
For an outgoing message that was assembled by the application itself, the
Destination objects encoding property may be used to override the
encodings of integer and floating point fields contained in the message. For
example, you can request that floating point values are stored in S/390
rather than IEEE format).
An incoming message is interpreted using the numeric encoding specified
in the message itself. This specification is in the rightmost WebSphere MQ
header (or MQMD if there are no headers). For JMS messages, the
rightmost header will usually be the MQRFH2.
If a BytesMessage is received, and is resent without modification, its body
is transmitted byte for byte, as it was received. The Destination objects
encoding property has no effect on the body. The only string-like entity
that can be sent explicitly in a BytesMessage is a UTF8 string. This is
Chapter 12. JMS messages
241
where:
datatype can take one of the values described in Table 19 on page 232.
string is the default datatype, so dt=string is omitted.
The character set used to encode or interpret the XML string that makes up
the MapMessage body is determined following the rules that apply to a
TextMessage.
StreamMessage
is like a map, but without element names:
<stream><elt dt=datatype>value</elt>
<elt dt=datatype>value</elt>.....</stream>
Every element is sent using the same tagname (elt). The default type is
string, so dt=string is omitted for string elements.
The character set used to encode or interpret the XML string that makes up
the StreamMessage body is determined following the rules that apply to a
TextMessage.
The MQRFH2.format field is set as follows:
MQFMT_NONE
for ObjectMessage, BytesMessage, or messages with no body.
MQFMT_STRING
for TextMessage, StreamMessage, or MapMessage.
242
ConnectionConsumer
The JMS specification enables an application server to integrate closely with a JMS
implementation by using the ConnectionConsumer interface. This feature provides
concurrent processing of messages. Typically, an application server creates a pool
Copyright IBM Corp. 1997, 2002
243
Planning an application
General principles for point-to-point messaging
When an application creates a ConnectionConsumer from a QueueConnection
object, it specifies a JMS Queue object and a selector string. The
ConnectionConsumer then begins to receive messages (or, more accurately, to
provide messages to Sessions in the associated ServerSessionPool). Messages arrive
on the queue, and if they match the selector, they are delivered to Sessions in the
associated ServerSessionPool.
In WebSphere MQ terms, the Queue object refers to either a QLOCAL or a
QALIAS on the local queue manager. If it is a QALIAS, that QALIAS must refer to
a QLOCAL. The fully resolved WebSphere MQ QLOCAL is known as the
underlying QLOCAL. A ConnectionConsumer is said to be active if it is not closed
and its parent QueueConnection is started.
It is possible for multiple ConnectionConsumers, each with different selectors, to
run against the same underlying QLOCAL. To maintain performance, unwanted
messages should not accumulate on the queue. Unwanted messages are those for
which no active ConnectionConsumer has a matching selector. You can set the
QueueConnectionFactory so that these unwanted messages are removed from the
queue (for details, see Removing messages from the queue on page 247). You can
set this behavior in one of two ways:
v Use the JMS Administration tool to set the QueueConnectionFactory to
MRET(NO).
v In your program, use:
MQQueueConnectionFactory.setMessageRetention(JMSC.MQJMS_MRET_NO)
If you do not change this setting, the default is to retain such unwanted messages
on the queue.
It is possible that ConnectionConsumers that target the same underlying QLOCAL
could be created from multiple QueueConnection objects. However, for
performance reasons, we recommend that multiple JVMs do not create
ConnectionConsumers against the same underlying QLOCAL.
244
v The user that runs the ConnectionConsumer must have authority to perform
MQOPEN with MQOO_SAVE_ALL_CONTEXT and
MQOO_PASS_ALL_CONTEXT. For details, see the WebSphere MQ
documentation for your specific platform.
v If unwanted messages are left on the queue, they degrade the system
performance. Therefore, plan your message selectors so that between them, the
ConnectionConsumers will remove all messages from the queue.
For details about MQSC commands, see WebSphere MQ Script (MQSC) Command
Reference.
v The user that runs the ConnectionConsumer must have authority to perform
MQOPEN with MQOO_SAVE_ALL_CONTEXT and
Chapter 13. WebSphere MQ JMS Application Server Facilities
245
For publish/subscribe messaging, if your system creates a dynamic queue for each
subscription, these settings are obtained from the WebSphere MQ JMS model
queue. To alter these settings, you can use:
ALTER QMODEL(SYSTEM.JMS.MODEL.QUEUE) BOTHRESH(threshold) BOQUEUE(your.requeue.queue.name)
If the threshold is zero, poison message handling is disabled, and poison messages
will remain on the input queue. Otherwise, when the backout count reaches the
246
247
Error handling
Recovering from error conditions
If a ConnectionConsumer experiences a serious error, message delivery to all
ConnectionConsumers with an interest in the same QLOCAL stops. Typically, this
occurs if the ConnectionConsumer cannot requeue a message to the dead-letter
queue, or it experiences an error when reading messages from the QLOCAL.
When this occurs, the application and application server are notified in the
following way:
v Any ExceptionListener that is registered with the affected Connection is notified.
You can use these to identify the cause of the problem. In some cases, the system
administrator must intervene to resolve the problem.
There are two ways in which an application can recover from these error
conditions:
v Call close() on all affected ConnectionConsumers. The application can create
new ConnectionConsumers only after all affected ConnectionConsumers are
closed and any system problems are resolved.
v Call stop() on all affected Connections. Once all Connections are stopped and
any system problems are resolved, the application should be able to start() all
Connections successfully.
248
|
|
|
Action
Action
Action
Other codes that appear in these fields are caused by a failed attempt to requeue
the message to a Backout Queue. In this situation, the code describes the reason
that the requeue failed. To diagnose the cause of these errors, refer to the
WebSphere MQ Application Programming Reference.
If the report message cannot be put on the ReplyToQ, it is put on the dead-letter
queue. In this situation, the feedback field of the MQMD is filled in as described
above. The reason field in the MQDLH explains why the report message could not
be placed on the ReplyToQ.
249
4
6
JMS Session
5
8
A B
ServerSessionPool
SSt
JMS Session
SSa
8
C D E
SSu
Server sessions
B C D E
F G
Message queue
250
These samples enable you to use the WebSphere MQ JMS ASF in a standalone
environment (that is, you do not need a suitable application server). Also, they
provide examples of how to implement these interfaces and take advantage of the
WebSphere MQ JMS ASF. These examples are intended to aid both WebSphere MQ
JMS users, and vendors of other application servers.
MyServerSession.java
This class implements the javax.jms.ServerSession interface. Its basic function is
to associate a thread with a JMS Session. Instances of this class are pooled by a
ServerSessionPool (see MyServerSessionPool.java). As a ServerSession, it must
implement the following two methods:
v getSession(), which returns the JMS Session this associated with this
ServerSession
v start(), which starts this ServerSessions thread and results in the JMS Sessions
run() method being invoked
MyServerSession also implements the Runnable interface. Therefore, the creation of
the ServerSessions thread can be based on this class, and does not need a separate
class.
The class uses a wait()-notify() mechanism that is based on the values of two
boolean flags, ready and quit. This mechanism means that the ServerSession
creates and starts its associated thread during its construction. However, it does
not automatically execute the body of the run() method. The body of the run()
method is executed only when the ready flag is set to true by the start() method.
The ASF calls the start() method when it is necessary to deliver messages to the
associated JMS Session.
For delivery, the run() method of the JMS Session is called. The WebSphere MQ
JMS ASF will have already loaded the run() method with messages.
After delivery completes, the ready flag is reset to false, and the owning
ServerSessionPool is notified that delivery is complete. The ServerSession then
remains in a wait state until either the start() method is called again, or the
close() method is invoked and ends this ServerSessions thread.
MyServerSessionPool.java
This class implements the javax.jms.ServerSessionPool interface, and exists to
create and control access to a pool of ServerSessions.
In this simple implementation, the pool consists of a static array of ServerSession
objects that are created during the construction of the pool. The following four
parameters are passed into the constructor:
v javax.jms.Connection connection
The connection used to create JMS Sessions.
v int capacity
Chapter 13. WebSphere MQ JMS Application Server Facilities
251
MessageListenerFactory.java
In this sample, a message listener factory object is associated with each
ServerSessionPool instance. The MessageListenerFactory class represents a very
simple interface that is used to obtain an instance of a class that implements the
javax.jms.MessageListener interface. The class contains a single method:
javax.jms.MessageListener createMessageListener();
252
ASFClient4.java
TopicLoad.java
CountingMessageListenerFactory.java
LoggingMessageListenerFactory.java
Load1.java
This class is a simple generic JMS application that loads a given queue with a
number of messages, then terminates. It can either retrieve the required
administered objects from a JNDI namespace, or create them explicitly, using the
WebSphere MQ JMS classes that implement these interfaces. The administered
objects that are required are a QueueConnectionFactory and a Queue. You can use
the command line options to set the number of messages with which to load the
queue, and the sleep time between individual message puts.
This application has two versions of the command line syntax.
For use with JNDI, the syntax is:
java Load1 [-icf jndiICF] [-url jndiURL] [-qcfLookup qcfLookup]
[-qLookup qLookup] [-sleep sleepTime] [-msgs numMsgs]
253
Meaning
Default
jndiICF
com.sun.jndi.ldap.LdapCtxFactory
jndiURL
ldap://localhost/o=ibm,c=us
qcfLookup
cn=qcf
qLookup
cn=q
qName
SYSTEM.DEFAULT.LOCAL.QUEUE
sleepTime
0 (no pause)
numMsgs
1000
If there are any errors, an error message is displayed, and the application
terminates.
You can use this application to simulate message load on a WebSphere MQ queue.
In turn, this message load could trigger the ASF-enabled applications described in
the following sections. The messages put to the queue are simple JMS TextMessage
objects. These objects do not contain user-defined message properties, which could
be useful to make use of different message listeners. The source code is supplied so
that you can modify this load application if necessary.
CountingMessageListenerFactory.java
This file contains definitions for two classes:
v CountingMessageListener
v CountingMessageListenerFactory
CountingMessageListener is a very simple implementation of the
javax.jms.MessageListener interface. It keeps a record of the number of times its
onMessage method has been invoked, but does nothing with the messages it is
passed.
CountingMessageListenerFactory is the factory class for CountingMessageListener.
It is an implementation of the MessageListenerFactory interface described in
MessageListenerFactory.java on page 252. This factory keeps a record of all the
message listeners that it produces. It also includes a method, printStats(), which
displays usage statistics for each of these listeners.
254
ASFClient1.java
This application acts as a client of the WebSphere MQ JMS ASF. It sets up a single
ConnectionConsumer to consume the messages in a single WebSphere MQ queue.
It displays throughput statistics for each message listener that is used, and
terminates after one minute.
The application can either retrieve the required administered objects from a JNDI
namespace, or create them explicitly, using the WebSphere MQ JMS classes that
implement these interfaces. The administered objects that are required are a
QueueConnectionFactory and a Queue.
This application has two versions of the command line syntax:
For use with JNDI, the syntax is:
java ASFClient1 [-icf jndiICF] [-url jndiURL] [-qcfLookup qcfLookup]
[-qLookup qLookup] [-poolSize poolSize] [-batchSize batchSize]
Meaning
Default
jndiICF
com.sun.jndi.ldap.LdapCtxFactory
jndiURL
ldap://localhost/o=ibm,c=us
qcfLookup
cn=qcf
qLookup
cn=q
qName
SYSTEM.DEFAULT.LOCAL.QUEUE
poolSize
batchSize
10
255
Load2.java
This class is a JMS application that loads a given queue with a number of
messages, then terminates, in a similar way to Load1.java. The command line
syntax is also similar to that for Load1.java (substitute Load2 for Load1 in the
syntax). For details, see Load1.java on page 253.
The difference is that each message contains a user property called value, which
takes a randomly selected integer value between 0 and 100. This property means
that you can apply message selectors to the messages. Consequently, the messages
can be shared between the two consumers that are created in the client application
described in ASFClient2.java.
LoggingMessageListenerFactory.java
This file contains definitions for two classes:
v LoggingMessageListener
v LoggingMessageListenerFactory
LoggingMessageListener is an implementation of the javax.jms.MessageListener
interface. It takes the messages that are passed to it and writes an entry to the log
file. The default log file is ./ASFClient2.log. You can inspect this file and check
the messages that are sent to the connection consumer that is using this message
listener.
LoggingMessageListenerFactory is the factory class for LoggingMessageListener. It
is an implementation of the MessageListenerFactory interface described in
MessageListenerFactory.java on page 252.
ASFClient2.java
ASFClient2.java is a slightly more complicated client application than
ASFClient1.java. It creates two ConnectionConsumers that feed off the same queue,
but that apply different message selectors. The application uses a
CountingMessageListenerFactory for one consumer, and a
LoggingMessageListenerFactory for the other. Use of two different message listener
factories means that each consumer must have its own server session pool.
The application displays statistics that relate to one ConnectionConsumer on
screen, and writes statistics that relate to the other ConnectionConsumer to a log
file.
256
TopicLoad.java
This class is a JMS application that is a publish/subscribe version of the Load2
queue loader described in Load2.java on page 256. It publishes the required
number of messages under the given topic, then it terminates. Each message
contains a user property called value, which takes a randomly selected integer
value between 0 and 100.
To use this application, ensure that the broker is running and that the required
setup is complete. For details, see Additional setup for publish/subscribe mode
on page 24.
This application has two versions of the command line syntax.
For use with JNDI, the syntax is:
java TopicLoad [-icf jndiICF] [-url jndiURL] [-tcfLookup tcfLookup]
[-tLookup tLookup] [-sleep sleepTime] [-msgs numMsgs]
Meaning
Default
jndiICF
com.sun.jndi.ldap.LdapCtxFactory
jndiURL
ldap://localhost/o=ibm,c=us
257
Meaning
Default
tcfLookup
cn=tcf
tLookup
cn=t
tName
MQJMS/ASF/TopicLoad
sleepTime
0 (no pause)
numMsgs
200
If there are any errors, an error message is displayed, and the application
terminates.
ASFClient3.java
ASFClient3.java is a client application that is a publish/subscribe version of
ASFClient1.java on page 255. It sets up a single ConnectionConsumer to consume
the messages published on a single Topic. It displays throughput statistics for each
message listener that is used, and terminates after one minute.
This application has two versions of the command line syntax.
For use with JNDI, the syntax is:
java ASFClient3 [-icf jndiICF] [-url jndiURL] [-tcfLookup tcfLookup]
[-tLookup tLookup] [-poolsize poolSize] [-batchsize batchSize]
258
Parameter
Meaning
Default
jndiICF
com.sun.jndi.ldap.LdapCtxFactory
jndiURL
ldap://localhost/o=ibm,c=us
tcfLookup
cn=tcf
tLookup
cn=t
tName
MQJMS/ASF/TopicLoad
poolSize
Meaning
Default
batchSize
10
Like ASFClient1, the client application displays throughput statistics for each
message listener that is used, displaying statistics every 10 seconds. After one
minute, the connection is closed, the server session pool is stopped, and the
application terminates.
ASFClient4.java
ASFClient4.java is a more complex publish/subscribe client application. It creates
three ConnectionConsumers that all feed off the same topic, but each one applies
different message selectors.
The first two consumers use high and normal message selectors, in the same
way as the application ASFClient2.java on page 256. The third consumer does
not use any message selector. The application uses two
CountingMessageListenerFactories for the two selector-based consumers, and a
LoggingMessageListenerFactory for the third consumer. Because the application
uses different message listener factories, each consumer must have its own server
session pool.
The application displays statistics that relate to the two selector-based consumers
on screen. It writes statistics that relate to the third ConnectionConsumer to a log
file.
The command line syntax is similar to that for ASFClient3.java on page 258
(substitute ASFClient4 for ASFClient3 in the syntax). Each of the three server
session pools contains the number of ServerSessions set by the poolSize parameter.
When the client application runs, statistics that relate to the
normalConnectionConsumer and the highConnectionConsumer, and their
associated CountingMessageListenerFactories, are printed to screen every 10
seconds. Statistics that relate to the third ConnectionConsumer, and its associated
LoggingMessageListenerFactories, are written to the log file.
You can inspect the screen and the log file to see the real destination of the
messages. Add the totals for each of the CountingMessageListeners and inspect the
number of log file entries.
The distribution of messages should be different from the distribution obtained by
a point-to-point version of the same application (ASFClient2.java). This is because,
in the publish/subscribe domain, each consumer of a topic obtains its own copy of
each message published on that topic. In this application, for a given topic load,
the high and normal consumers will receive approximately 25% and 75% of the
load, respectively. The third consumer will still receive 100% of the load. Therefore,
the total number of messages received is greater than 100% of the load originally
published on the topic.
259
ASFClient5.java
This sample exercises the durable publish/subscribe ConnectionConsumer
functionality in WebSphere MQ JMS.
You invoke it with the same command-line options as the ASFClient4 sample, and,
as with the other samples, the TopicLoad sample application can be used to trigger
the consumer that is created. For details of TopicLoad, see TopicLoad.java on
page 257.
When invoked, ASFClient5 displays a menu of three options:
1. Create/reactivate a durable ConnectionConsumer
2. Unsubscribe a durable ConnectionConsumer
X. Exit
If option 1 is chosen, and this is the first time this sample has been run, then a
brand new durable ConnectionConsumer will be created using the given name. It
will then display one minutes worth of throughput statistics, rather like the other
samples, before closing the connection and terminating.
Having created a durable consumer, messages published on the topic in question
will continue to arrive at the consumers destination even though the consumer is
inactive.
This can be confirmed by running ASFClient5 again, and again selecting option 1.
This will reactivate the named durable consumer, and the statistics displayed will
show that any relevant messages published during the period of inactivity were
subsequently delivered to the consumer.
If you run ASFClient5 once again and select option 2, this will unsubscribe the
named durable ConnectionConsumer and discard any outstanding messages
delivered to it. Do this to ensure that the broker does not continue to deliver
unwanted messages.
260
Description
BytesMessage
Connection
ConnectionConsumer
ConnectionFactory
ConnectionMetaData
DeliveryMode
Destination
ExceptionListener*
MapMessage
Message
MessageConsumer
MessageListener*
MessageProducer
ObjectMessage
Queue
261
javax.jms
Table 33. Summary of interfaces in package javax.jms (continued)
262
Interface
Description
QueueBrowser
QueueConnection
QueueConnectionFactory
QueueReceiver
QueueSender
QueueSession
ServerSession **
ServerSessionPool **
Session
StreamMessage
TemporaryQueue
TemporaryTopic
TextMessage
Topic
TopicConnection
TopicConnectionFactory
TopicPublisher
TopicSession
TopicSubscriber
XAConnection
XAConnectionFactory
XAQueueConnection
javax.jms
Table 33. Summary of interfaces in package javax.jms (continued)
Interface
Description
XAQueueConnectionFactory
XAQueueSession
XASession
XATopicConnection
XATopicConnectionFactory
XATopicSession
Description
QueueRequestor
TopicRequestor
263
Direct connection to
WebSphere MQ
Event Broker
implementation
Cleanup
Connection
MQConnection
ConnectionConsumer
MQConnectionConsumer
ConnectionFactory
MQConnectionFactory
ConnectionMetaData
MQConnectionMetaData
Destination
MQDestination
MessageConsumer
MQMessageConsumer
MessageProducer
MQMessageProducer
Queue
MQQueue
QueueBrowser
MQQueueBrowser
QueueConnection
MQQueueConnection
QueueConnectionFactory
MQQueueConnectionFactory
MQQueueEnumeration
264
QueueReceiver
MQQueueReceiver
QueueSender
MQQueueSender
QueueSession
MQQueueSession
Session
MQSession
TemporaryQueue
MQTemporaryQueue
TemporaryTopic
MQTemporaryTopic
Topic
MQTopic
TopicConnection
MQTopicConnection
TopicConnectionFactory
MQTopicConnectionFactory
TopicPublisher
MQTopicPublisher
TopicSession
MQTopicSession
TopicSubscriber
MQTopicSubscriber
XAConnection
MQXAConnection
XAConnectionFactory
MQXAConnectionFactory
XAQueueConnection
MQXAQueueConnection
XAQueueConnectionFactory
MQXAQueueConnectionFactory
XAQueueSession
MQXAQueueSession
XASession
MQXASession
XATopicConnection
MQXATopicConnection
XATopicConnectionFactory
MQXATopicConnectionFactory
XATopicSession
MQXATopicSession
Direct connection to
WebSphere MQ
Event Broker
implementation
Client or bindings
implementation
Direct connection to
WebSphere MQ
Event Broker
implementation
BytesMessage
MapMessage
Message
ObjectMessage
StreamMessage
TextMessage
265
BytesMessage
BytesMessage
public interface BytesMessage
extends Message
WebSphere MQ class: JMSBytesMessage
java.lang.Object
|
+----com.ibm.jms.JMSMessage
|
+----com.ibm.jms.JMSBytesMessage
Methods
readBoolean
public boolean readBoolean() throws JMSException
266
BytesMessage
readBytes
public int readBytes(byte[] value) throws JMSException
Read a byte array from the bytes message. If there are sufficient bytes
remaining in the stream the entire buffer is filled, if not, the buffer is
partially filled.
Parameters:
value - the buffer into which the data is read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no
more data because the end of the bytes has been reached.
Throws:
v MessageNotReadableException - if the message is in write-only
mode.
v JMSException - if JMS fails to read the message because of an
internal JMS error.
readBytes
public int readBytes(byte[] value, int length)
throws JMSException
267
BytesMessage
readDouble
public double readDouble() throws JMSException
268
BytesMessage
v JMSException - if JMS fails to read the message because of an
internal JMS error.
readShort
public short readShort() throws JMSException
269
BytesMessage
readUTF
public java.lang.String readUTF() throws JMSException
Read in a string that has been encoded using a modified UTF-8 format
from the bytes message. The first two bytes are interpreted as a 2-byte
length field.
Returns:
a Unicode string from the bytes message.
Throws:
v MessageNotReadableException - if the message is in write-only
mode.
v MessageEOFException - if it is the end of the message bytes.
v JMSException - if JMS fails to read the message because of an
internal JMS error.
reset
public void reset() throws JMSException
Put the message body in read-only mode, and reposition the bytes of bytes
to the beginning.
Throws:
v JMSException - if JMS fails to reset the message because of an
internal JMS error.
v MessageFormatException - if message has an incorrect format
writeBoolean
public void writeBoolean(boolean value) throws JMSException
Write a boolean to the bytes message as a 1-byte value. The value true is
written out as the value (byte)1; the value false is written out as the
value (byte)0.
Parameters:
value - the boolean value to be written.
Throws:
v MessageNotWriteableException - if message in read-only mode.
v JMSException - if JMS fails to write the message because of an
internal JMS error.
writeByte
public void writeByte(byte value) throws JMSException
270
BytesMessage
writeBytes
public void writeBytes(byte[] value) throws JMSException
Write a char to the bytes message as a 2-byte value, high byte first.
Parameters:
value - the char value to be written.
Throws:
v MessageNotWriteableException - if message in read-only mode.
v JMSException - if JMS fails to write the message because of an
internal JMS error.
writeDouble
public void writeDouble(double value) throws JMSException
271
BytesMessage
writeFloat
public void writeFloat(float value) throws JMSException
272
BytesMessage
writeShort
public void writeShort(short value) throws JMSException
273
Cleanup
Cleanup *
public class Cleanup
implements Runnable
WebSphere MQ class: Cleanup
Cleanup contains utilities for dealing with broken non-durable subscriptions using
the SUBSTATE(BROKER) option. It is not applicable if you use a direct connection
to WebSphere MQ Event Broker.
See also: ConnectionFactory.
WebSphere MQ constructor
Cleanup
public Cleanup()
Default constructor.
Cleanup
public Cleanup(MQTopicConnectionFactory mqtcf) throws JMSException
Methods
cleanup
public void cleanup() throws JMSException
274
Cleanup
getCleanupLevel
public int getCleanupLevel()
Get the initialization string that was passed to the receive exit class.
getSecurityExit
public String getSecurityExit()
275
Cleanup
getSendExitInit
public String getSendExitInit()
Allows the utility to be invoked from a command line. For details of the
invocation options and parameters, see Manual cleanup on page 222.
run
public void run()
Set the character set to be used when connecting to the queue manager. See
Table 13 on page 120 for a list of allowed values. We recommend that you
use the default value (819) for most situations.
setChannel
public void setChannel(String x) throws JMSException
276
Cleanup
setCleanupLevel
public void setCleanupLevel(int level) throws JMSException
277
Cleanup
setSecurityExit
public void setSecurityExit(String securityExit)
Stops any currently running cleanup thread. Returns when cleanup has
finished. Does nothing if cleanup is not running.
278
Connection
Connection
public interface Connection
Subinterfaces: QueueConnection, TopicConnection, XAQueueConnection, and
XATopicConnection
WebSphere MQ class: MQConnection
java.lang.Object
|
+----com.ibm.mq.jms.MQConnection
Methods
close
public void close() throws JMSException
Because a provider may allocate some resources outside the JVM on behalf
of a Connection, clients should close them when they are not needed. You
cannot rely on garbage collection to reclaim these resources eventually,
because this may not occur soon enough. There is no need to close the
sessions, producers, and consumers of a closed connection.
Closing a connection causes any of its sessions in-process transactions to
be rolled back. In the case where a sessions work is coordinated by an
external transaction manager, when using XASession, a sessions commit
and rollback methods are not used and the result of a closed sessions
work is determined later by a transaction manager. Closing a connection
does NOT force an acknowledge of client acknowledged sessions.
WebSphere MQ JMS keeps a pool of WebSphere MQ hConns available for
use by Sessions. Under some circumstances, Connection.close() clears this
pool. If an application uses multiple Connections sequentially, it is possible
to force the pool to remain active between JMS Connections. To do this,
register an MQPoolToken with com.ibm.mq.MQEnvironment for the
lifetime of your JMS application. For details, see Connection pooling on
page 73 and MQEnvironment on page 104.
Throws:
JMSException - if the JMS implementation fails to close the
connection because of an internal error. Examples are a failure to
release resources or to close a socket connection.
279
Connection
getClientID
public java.lang.String getClientID()
throws JMSException
Get the client identifier for this connection. The client identifier can either
be preconfigured by the administrator in a ConnectionFactory, or assigned
by calling setClientId.
Returns:
the unique client identifier.
Throws:
JMSException - if the JMS implementation fails to return the client
ID for this Connection because of an internal error.
getExceptionListener
public ExceptionListener getExceptionListener()
throws JMSException
280
Connection
v JMSException - if the JMS implementation fails to set the
client ID for this Connection because of an internal error.
v InvalidClientIDException - if the JMS client specifies a
non valid or duplicate client id.
v IllegalStateException - if attempting to set a connections
client identifier at the wrong time, or if it has been
configured administratively.
setExceptionListener
public void setExceptionListener(ExceptionListener listener)
throws JMSException
281
ConnectionConsumer
ConnectionConsumer
public interface ConnectionConsumer
WebSphere MQ class: MQConnectionConsumer
java.lang.Object
|
+----com.ibm.mq.jms.MQConnectionConsumer
Methods
close()
public void close() throws JMSException
282
ConnectionFactory
ConnectionFactory
public interface ConnectionFactory
Subinterfaces: QueueConnectionFactory, TopicConnectionFactory,
XAQueueConnectionFactory, and XATopicConnectionFactory
WebSphere MQ class: MQConnectionFactory
java.lang.Object
|
+----com.ibm.mq.jms.MQConnectionFactory
WebSphere MQ constructor
MQConnectionFactory
public MQConnectionFactory()
Methods
getCCSID *
public int getCCSID()
Get the client Identifier that is used for all connections that are created
using this ConnectionFactory.
283
ConnectionFactory
getDescription *
public String getDescription()
Get the initialization string that was passed to the receive exit class.
getSecurityExit *
public String getSecurityExit()
284
ConnectionFactory
getSendExit *
public String getSendExit()
getSSLCertStores *
public java.util.Collection getSSLCertStores()
285
ConnectionFactory
getUseConnectionPooling *
public boolean getUseConnectionPooling()
Set the character set to be used when connecting to the queue manager. See
Table 13 on page 120 for a list of allowed values. We recommend that you
use the default value (819) for most situations.
setChannel *
public void setChannel(String x) throws JMSException
Sets the client Identifier to be used for all connections created using this
Connection.
286
ConnectionFactory
setPort *
public void setPort(int port) throws JMSException
setSSLCertStores *
public void setSSLCertStores(java.util.Collection stores)
287
ConnectionFactory
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Specifies a list of LDAP servers used for CRL checking. This string must
consist of a sequence of space-delimited LDAP URIs of the form
ldap://host[:port]. If no port is specified, the LDAP default of 389 is
assumed. The certificate provided by the queue manager is checked against
one of the listed LDAP CRL servers; if found, the connection will fail. Each
LDAP server is tried in turn until one is successfully used to verify the
queue managers certificate. If set to null (default), no checking of the
queue managers certificate is performed. Throws JMSException if the
supplied list of LDAP URIs is not valid. This property is ignored if
sslCipherSuite is null. Use of this property requires Java 2 v1.4.
|
|
|
|
|
|
|
This should be set to the CipherSuite matching the CipherSpec set on the
SVRCONN channel. If set to null (default), no SSL encryption is
performed. See Appendix H, SSL CipherSuites supported by WebSphere
MQ on page 425 for a list of CipherSuites and their associated
CipherSpecs.
|
|
|
|
|
setSSLPeerName *
|
|
|
|
|
|
|
|
|
|
|
288
ConnectionFactory
|
|
setSSLSocketFactory *
public void setSSLSocketFactory(javax.net.ssl.SSLSocketFactory sf)
|
|
|
|
|
|
Sets the SSLSocketFactory for use with SSL encryption. This can be used to
customize all aspects of SSL encryption. For more information on
constructing and customizing SSLSocketFactory instances, refer to your
JSSE providers documentation. If set to null (default), the JSSE default
SSLSocketFactory is used when SSL encryption is requested. This property
is ignored if sslCipherSuite is null.
|
|
|
Choose whether or not all GET operations will be done within a syncpoint.
The default setting for this property is false. This allows GET operations
not under transaction management to perform more quickly.
setTransportType *
public void setTransportType(int x) throws JMSException
289
ConnectionMetaData
ConnectionMetaData
public interface ConnectionMetaData
WebSphere MQ class: MQConnectionMetaData
java.lang.Object
|
+----com.ibm.mq.jms.MQConnectionMetaData
WebSphere MQ constructor
MQConnectionMetaData
public MQConnectionMetaData()
Methods
getJMSMajorVersion
public int getJMSMajorVersion() throws JMSException
290
ConnectionMetaData
Returns:
the JMS version.
Throws:
JMSException - if an internal error occurs in JMS implementation
during the metadata retrieval.
getJMSXPropertyNames
public java.util.Enumeration getJMSXPropertyNames()
throws JMSException
Overrides:
toString in class Object.
Chapter 14. JMS interfaces and classes
291
DeliveryMode
DeliveryMode
public interface DeliveryMode
Delivery modes supported by JMS.
Fields
NON_PERSISTENT
public static final int NON_PERSISTENT
This is the lowest overhead delivery mode because it does not require that
the message be logged to stable storage.
PERSISTENT
public static final int PERSISTENT
This mode instructs the JMS provider to log the message to stable storage
as part of the clients send operation.
292
Destination
Destination
public interface Destination
Subinterfaces: Queue, TemporaryQueue, TemporaryTopic, and Topic
WebSphere MQ class: MQDestination
java.lang.Object
|
+----com.ibm.mq.jms.MQDestination
WebSphere MQ constructors
MQDestination
public MQDestination()
Methods
getCCSID *
public int getCCSID()
Get the name of the character set that is used by this destination.
getDescription *
public String getDescription()
293
Destination
Character set to be used to encode text strings in messages sent to this
destination. See Table 13 on page 120 for a list of allowed values. The
default value is 1208 (UTF8).
setDescription *
public void setDescription(String x)
294
ExceptionListener
ExceptionListener
public interface ExceptionListener
If a JMS provider detects a serious problem with a Connection, it will inform the
Connections ExceptionListener if one has been registered. It does this by calling
the listeners onException() method, passing it a JMSException that describes the
problem.
This allows a client to be asynchronously notified of a problem. Some Connections
only consume messages so they would have no other way to learn their
Connection has failed.
Exceptions are delivered when:
v There is a failure in receiving an asynchronous message
v A message throws a runtime exception
Methods
onException
public void onException(JMSException exception)
295
MapMessage
MapMessage
public interface MapMessage
extends Message
WebSphere MQ class: JMSMapMessage
java.lang.Object
|
+----com.ibm.jms.JMSMessage
|
+----com.ibm.jms.JMSMapMessage
A MapMessage is used to send a set of name-value pairs where names are Strings
and values are Java primitive types. The entries can be accessed sequentially or
randomly by name. The order of the entries is undefined.
See also: BytesMessage, Message, ObjectMessage, StreamMessage, and
TextMessage
Methods
getBoolean
public boolean getBoolean(java.lang.String name)
throws JMSException
296
MapMessage
getBytes
public byte[] getBytes(java.lang.String name) throws JMSException
297
MapMessage
getFloat
public float getFloat(java.lang.String name) throws JMSException
298
MapMessage
getMapNames
public java.util.Enumeration getMapNames() throws JMSException
Return the Java object value with the given name. This method returns in
object format, a value that has been stored in the Map either using the
setObject method call, or the equivalent primitive set method.
Parameters:
name - the name of the Java object.
Returns:
a copy of the Java object value with the given name, in object
format (if it is set as an int, then a Integer is returned). If there is
no item by this name, a null value is returned.
Throws:
JMSException - if JMS fails to read the message because of an
internal JMS error.
getShort
public short getShort(java.lang.String name) throws JMSException
299
MapMessage
v JMSException - if JMS fails to read the message because of an
internal JMS error.
v MessageFormatException - if this type conversion is not valid.
itemExists
public boolean itemExists(java.lang.String name)
throws JMSException
Set a boolean value with the given name into the Map.
Parameters:
v name - the name of the boolean.
v value - the boolean value to set in the Map.
Throws:
v JMSException - if JMS fails to write message due to some
internal JMS error.
v MessageNotWriteableException - if the message is in read-only
mode.
setByte
public void setByte(java.lang.String name,
byte value) throws JMSException
Set a byte value with the given name into the Map.
Parameters:
v name - the name of the byte.
v value - the byte value to set in the Map.
Throws:
v JMSException - if JMS fails to write message due to some
internal JMS error
v MessageNotWriteableException - if the message is in read-only
mode.
300
MapMessage
setBytes
public void setBytes(java.lang.String name,
byte[] value) throws JMSException
Set a byte array value with the given name into the Map.
Parameters:
v name - the name of the byte array.
v value - the byte array value to set in the Map.
The array is copied, so the value in the map is not altered by
subsequent modifications to the array.
Throws:
v JMSException - if JMS fails to write message due to some
internal JMS error.
v MessageNotWriteableException - if the message is in read-only
mode.
setBytes
public void setBytes(java.lang.String name,
byte[] value,
int offset,
int length) throws JMSException
Set a portion of the byte array value with the given name into the Map.
The array is copied, so the value in the map is not altered by subsequent
modifications to the array.
Parameters:
v
v
v
v
Throws:
v JMSException - if JMS fails to write message due to some
internal JMS error.
v MessageNotWriteableException - if the message is in read-only
mode.
setChar
public void setChar(java.lang.String name,
char value) throws JMSException
Set a Unicode character value with the given name into the Map.
Parameters:
v name - the name of the Unicode character.
v value - the Unicode character value to set in the Map.
Throws:
v JMSException - if JMS fails to write message due to some
internal JMS error.
v MessageNotWriteableException - if the message is in read-only
mode.
Chapter 14. JMS interfaces and classes
301
MapMessage
setDouble
public void setDouble(java.lang.String name,
double value) throws JMSException
Set a double value with the given name into the Map.
Parameters:
v name - the name of the double.
v value - the double value to set in the Map.
Throws:
v JMSException - if JMS fails to write message due to some
internal JMS error.
v MessageNotWriteableException - if the message is in read-only
mode.
setFloat
public void setFloat(java.lang.String name,
float value) throws JMSException
Set a float value with the given name into the Map.
Parameters:
v name - the name of the float.
v value - the float value to set in the Map.
Throws:
v JMSException - if JMS fails to write message due to some
internal JMS error.
v MessageNotWriteableException - if the message is in read-only
mode.
setInt
public void setInt(java.lang.String name,
int value) throws JMSException
Set an integer value with the given name into the Map.
Parameters:
v name - the name of the integer.
v value - the integer value to set in the Map.
Throws:
v JMSException - if JMS fails to write message due to some
internal JMS error.
v MessageNotWriteableException - if the message is in read-only
mode.
302
MapMessage
setLong
public void setLong(java.lang.String name,
long value) throws JMSException
Set a long value with the given name into the Map.
Parameters:
v name - the name of the long.
v value - the long value to set in the Map.
Throws:
v JMSException - if JMS fails to write message due to some
internal JMS error.
v MessageNotWriteableException - if the message is in read-only
mode.
setObject
public void setObject(java.lang.String name,
java.lang.Object value) throws JMSException
Set a Java object value with the given name into the Map. This method
only works for object primitive types (Integer, Double, Long, for example),
Strings and byte arrays.
Parameters:
v name - the name of the Java object.
v value - the Java object value to set in the Map.
Throws:
v JMSException - if JMS fails to write message due to some
internal JMS error.
v MessageFormatException - if object is not valid.
v MessageNotWriteableException - if the message is in read-only
mode.
setShort
public void setShort(java.lang.String name,
short value) throws JMSException
Set a short value with the given name into the Map.
Parameters:
v name - the name of the short.
v value - the short value to set in the Map.
Throws:
v JMSException - if JMS fails to write message due to some
internal JMS error.
v MessageNotWriteableException - if the message is in read-only
mode.
303
MapMessage
setString
public void setString(java.lang.String name,
java.lang.String value) throws JMSException
Set a String value with the given name into the Map.
Parameters:
v name - the name of the String.
v value - the String value to set in the Map.
Throws:
v JMSException - if JMS fails to write message due to some
internal JMS error.
v MessageNotWriteableException - if the message is in read-only
mode.
304
Message
Message
public interface Message
Subinterfaces: BytesMessage, MapMessage, ObjectMessage,
StreamMessage, and TextMessage
WebSphere MQ class: JMSMessage
java.lang.Object
|
+----com.ibm.jms.MQJMSMessage
The Message interface is the root interface of all JMS messages. It defines the JMS
header and the acknowledge method used for all messages.
Fields
DEFAULT_DELIVERY_MODE
public static final int DEFAULT_DELIVERY_MODE
Methods
acknowledge
public void acknowledge() throws JMSException
Clear out the message body. All other parts of the message are left
untouched.
Throws:
JMSException - if JMS fails to because of an internal JMS error.
305
Message
clearProperties
public void clearProperties() throws JMSException
Clear a messages properties. The header fields and message body are not
cleared.
Throws:
JMSException - if JMS fails to clear JMS message properties
because of an internal JMS error.
getBooleanProperty
public boolean getBooleanProperty(java.lang.String name)
throws JMSException
306
Message
getFloatProperty
public float getFloatProperty(java.lang.String name)
throws JMSException
307
Message
getJMSCorrelationIDAsBytes
public byte[] getJMSCorrelationIDAsBytes()
throws JMSException
308
Message
getJMSMessageID
public java.lang.String getJMSMessageID()
throws JMSException
309
Message
See also:
setJMSReplyTo()
getJMSTimestamp
public long getJMSTimestamp() throws JMSException
Return the Java object property value with the given name.
Parameters:
name - the name of the Java object property.
Returns:
the Java object property value with the given name, in object
format (for example, if it set as an int, an Integer is returned). If
there is no property by this name, a null value is returned.
310
Message
Throws:
JMSException - if JMS fails to get the property because of an
internal JMS error.
getPropertyNames
public java.util.Enumeration getPropertyNames()
throws JMSException
311
Message
propertyExists
public boolean propertyExists(java.lang.String name)
throws JMSException
Set a boolean property value with the given name into the Message.
Parameters:
v name - the name of the boolean property.
v value - the boolean property value to set in the Message.
Throws:
v JMSException - if JMS fails to set Property because of an internal
JMS error.
v MessageNotWriteableException - if the properties are read-only.
setByteProperty
public void setByteProperty(java.lang.String name,
byte value) throws JMSException
Set a byte property value with the given name into the Message.
Parameters:
v name - the name of the byte property.
v value - the byte property value to set in the Message.
Throws:
v JMSException - if JMS fails to set Property because of an internal
JMS error.
v MessageNotWriteableException - if the properties are read-only.
setDoubleProperty
public void setDoubleProperty(java.lang.String name,
double value) throws JMSException
Set a double property value with the given name into the Message.
Parameters:
v name - the name of the double property.
v value - the double property value to set in the Message.
312
Message
Throws:
v JMSException - if JMS fails to set the property because of an
internal JMS error.
v MessageNotWriteableException - if the properties are read-only.
setFloatProperty
public void setFloatProperty(java.lang.String name,
float value) throws JMSException
Set a float property value with the given name into the Message.
Parameters:
v name - the name of the float property.
v value - the float property value to set in the Message.
Throws:
v JMSException - if JMS fails to set the property because of an
internal JMS error.
v MessageNotWriteableException - if the properties are read-only.
setIntProperty
public void setIntProperty(java.lang.String name,
int value) throws JMSException
Set an integer property value with the given name into the Message.
Parameters:
v name - the name of the integer property.
v value - the integer property value to set in the Message.
Throws:
v JMSException - if JMS fails to set Property because of an internal
JMS error.
v MessageNotWriteableException - if the properties are read-only.
setJMSCorrelationID
public void setJMSCorrelationID
(java.lang.String correlationID)
throws JMSException
313
Message
setJMSCorrelationIDAsBytes
public void setJMSCorrelationIDAsBytes(byte[]
correlationID)
throws JMSException
Set the correlation ID as an array of bytes for the message. A client can use
this call to set the correlationID equal either to a messageID from a
previous message, or to an application-specific string. Application-specific
strings must not start with the characters ID:
Parameters:
correlationID - the correlation ID as a string, or the message ID of
a message being referred to.
Throws:
JMSException - if JMS fails to set the correlation ID because of an
internal JMS error.
See also:
setJMSCorrelationID(), getJMSCorrelationID(),
getJMSCorrelationIDAsBytes()
setJMSDeliveryMode
public void setJMSDeliveryMode(int deliveryMode)
throws JMSException
314
Message
See also:
getJMSDestination()
setJMSExpiration
public void setJMSExpiration(long expiration)
throws JMSException
315
Message
setJMSRedelivered
public void setJMSRedelivered(boolean redelivered)
throws JMSException
316
Message
setJMSType
public void setJMSType(java.lang.String type)
throws JMSException
Set a long property value with the given name into the Message.
Parameters:
v name - the name of the long property.
v value - the long property value to set in the Message.
Throws:
v JMSException - if JMS fails to set Property because of an internal
JMS error.
v MessageNotWriteableException - if the properties are read-only.
setObjectProperty
public void setObjectProperty(java.lang.String name,
java.lang.Object value) throws JMSException
Set a property value with the given name into the Message.
Parameters:
v name - the name of the Java object property.
v value - the Java object property value to set in the Message.
Throws:
v JMSException - if JMS fails to set Property because of an internal
JMS error.
v MessageFormatException - if the object is not valid.
v MessageNotWriteableException - if the properties are read-only.
317
Message
setShortProperty
public void setShortProperty(java.lang.String name,
short value) throws JMSException
Set a short property value with the given name into the Message.
Parameters:
v name - the name of the short property.
v value - the short property value to set in the Message.
Throws:
v JMSException - if JMS fails to set Property because of an internal
JMS error.
v MessageNotWriteableException - if the properties are read-only.
setStringProperty
public void setStringProperty(java.lang.String name,
java.lang.String value) throws JMSException
Set a String property value with the given name into the Message.
Parameters:
v name - the name of the String property.
v value - the String property value to set in the Message.
Throws:
v JMSException - if JMS fails to set the property because of an
internal JMS error.
v MessageNotWriteableException - if the properties are read-only.
318
MessageConsumer
MessageConsumer
public interface MessageConsumer
Subinterfaces: QueueReceiver and TopicSubscriber
WebSphere MQ class: MQMessageConsumer
java.lang.Object
|
+----com.ibm.mq.jms.MQMessageConsumer
The parent interface for all message consumers. A client uses a message consumer
to receive messages from a Destination.
Methods
getMessageListener
public MessageListener getMessageListener()
throws JMSException
319
MessageConsumer
receive
public Message receive(long timeOut) throws JMSException
Receive the next message that arrives within the specified timeout interval.
A timeout value of zero causes the call to wait indefinitely until a message
arrives.
Parameters:
timeout - the timeout value (in milliseconds).
Returns:
the next message produced for this message consumer, or null if
one is not available.
Throws:
JMSException - if JMS fails to receive the next message because of
an error.
receiveNoWait
public Message receiveNoWait() throws JMSException
320
MessageListener
MessageListener
public interface MessageListener
A MessageListener is used to receive asynchronously delivered messages.
Methods
onMessage
public void onMessage(Message message)
321
MessageProducer
MessageProducer
public interface MessageProducer
Subinterfaces: QueueSender and TopicPublisher
WebSphere MQ class: MQMessageProducer
java.lang.Object
|
+----com.ibm.mq.jms.MQMessageProducer
WebSphere MQ constructors
MQMessageProducer
public MQMessageProducer()
Methods
close
public void close() throws JMSException
322
MessageProducer
getDisableMessageTimestamp
public boolean getDisableMessageTimestamp()
throws JMSException
Get the default length of time in milliseconds from its dispatch time that a
produced message should be retained by the message system.
Returns:
the message time to live in milliseconds; zero is unlimited.
Throws:
JMSException - if JMS fails to get the Time to Live because of an
internal error.
See also:
setTimeToLive
setDeliveryMode
public void setDeliveryMode(int deliveryMode)
throws JMSException
323
MessageProducer
setDisableMessageID
public void setDisableMessageID(boolean value)
throws JMSException
324
MessageProducer
setTimeToLive
public void setTimeToLive(long timeToLive)
throws JMSException
Set the default length of time, in milliseconds from its dispatch time, that a
produced message should be retained by the message system.
Time to live is set to zero by default.
325
MQQueueEnumeration
MQQueueEnumeration *
public class MQQueueEnumeration
extends Object
implements Enumeration
java.lang.Object
|
+----com.ibm.mq.jms.MQQueueEnumeration
Methods
hasMoreElements
public boolean hasMoreElements()
326
ObjectMessage
ObjectMessage
public interface ObjectMessage
extends Message
WebSphere MQ class: JMSObjectMessage
java.lang.Object
|
+----com.ibm.jms.JMSMessage
|
+----com.ibm.jms.JMSObjectMessage
Methods
getObject
public java.io.Serializable getObject()
throws JMSException
Get the serializable object containing this messages data. The default value
is null.
Returns:
the serializable object containing this messages data.
Throws:
v JMSException - if JMS fails to get the object because of an
internal JMS error.
v MessageFormatException - if object deserialization fails.
setObject
public void setObject(java.io.Serializable object)
throws JMSException
327
Queue
Queue
public interface Queue
extends Destination
Subinterfaces: TemporaryQueue
WebSphere MQ class: MQQueue
java.lang.Object
|
+----com.ibm.mq.jms.MQDestination
|
+----com.ibm.mq.jms.MQQueue
WebSphere MQ constructors
MQQueue *
public MQQueue()
Methods
getBaseQueueManagerName *
public String getBaseQueueManagerName()
Returns:
the value of the WebSphere MQ Queue manager name.
getBaseQueueName *
public String getBaseQueueName()
Returns:
the value of the WebSphere MQ Queue name.
getQueueName
public java.lang.String getQueueName()
throws JMSException
328
Queue
Throws:
JMSException - if JMS implementation for Queue fails to return the
queue name because of an internal error.
getReference *
public Reference getReference() throws NamingException
329
QueueBrowser
QueueBrowser
public interface QueueBrowser
WebSphere MQ class: MQQueueBrowser
java.lang.Object
|
+----com.ibm.mq.jms.MQQueueBrowser
Methods
close
public void close() throws JMSException
Get an enumeration for browsing the current queue messages in the order
that they would be received.
Returns:
an enumeration for browsing the messages.
Throws:
JMSException - if JMS fails to get the enumeration for this browser
because of a JMS error.
Note: If the browser is created for a nonexistent queue, this is not
detected until the first call to getEnumeration.
getMessageSelector
public java.lang.String getMessageSelector() throws JMSException
330
QueueBrowser
getQueue
public Queue getQueue() throws JMSException
331
QueueConnection
QueueConnection
public interface QueueConnection
extends Connection
Subinterfaces: XAQueueConnection
WebSphere MQ class: MQQueueConnection
java.lang.Object
|
+----com.ibm.mq.jms.MQConnection
|
+----com.ibm.mq.jms.MQQueueConnection
Methods
close *
public void close() throws JMSException
Overrides:
close in class MQConnection.
createConnectionConsumer
public ConnectionConsumer createConnectionConsumer
(Queue queue,
java.lang.String messageSelector,
ServerSessionPool sessionPool,
int maxMessages)
throws JMSException
332
QueueConnection
Returns:
the connection consumer.
Throws:
v JMSException - if the JMS Connection fails to create a connection
consumer because of an internal error, or incorrect arguments for
sessionPool and messageSelector.
v InvalidSelectorException - if the message selector is not valid.
See Also:
ConnectionConsumer
createQueueSession
public QueueSession createQueueSession(boolean transacted,
int acknowledgeMode)
throws JMSException
Create a QueueSession.
Parameters:
v transacted - if true, the session is transacted.
v acknowledgeMode - indicates whether the consumer or the
client will acknowledge any messages it receives. Possible values
are:
Session.AUTO_ACKNOWLEDGE
Session.CLIENT_ACKNOWLEDGE
Session.DUPS_OK_ACKNOWLEDGE
This parameter is ignored if the session is transacted.
Returns:
a newly created queue session.
Throws:
JMSException - if JMS Connection fails to create a session because
of an internal error, or lack of support for specific transaction and
acknowledgement mode.
333
QueueConnectionFactory
QueueConnectionFactory
public interface QueueConnectionFactory
extends ConnectionFactory
Subinterfaces: XAQueueConnectionFactory
WebSphere MQ class: MQQueueConnectionFactory
java.lang.Object
|
+----com.ibm.mq.jms.MQConnectionFactory
|
+----com.ibm.mq.jms.MQQueueConnectionFactory
WebSphere MQ constructor
MQQueueConnectionFactory
public MQQueueConnectionFactory()
Methods
createQueueConnection
public QueueConnection createQueueConnection()
throws JMSException
334
QueueConnectionFactory
Parameters:
v userName - the callers user name.
v password - the callers password.
Returns:
a newly created queue connection.
Throws:
v JMSException - if JMS Provider fails to create Queue
Connection because of an internal error.
v JMSSecurityException - if client authentication fails
because of a non valid user name or password.
getMessageRetention*
public int getMessageRetention()
setMessageRetention*
public void setMessageRetention(int x) throws JMSException
335
QueueReceiver
QueueReceiver
public interface QueueReceiver
extends MessageConsumer
WebSphere MQ class: MQQueueReceiver
java.lang.Object
|
+----com.ibm.mq.jms.MQMessageConsumer
|
+----com.ibm.mq.jms.MQQueueReceiver
A client uses a QueueReceiver for receiving messages that have been delivered to a
queue.
See also: MessageConsumer
This class inherits the following methods from MQMessageConsumer.
v receive
v receiveNoWait
v close
v getMessageListener
v setMessageListener
Methods
getQueue
public Queue getQueue() throws JMSException
336
QueueRequestor
QueueRequestor
public class QueueRequestor
extends java.lang.Object
java.lang.Object
|
+----javax.jms.QueueRequestor
Constructors
QueueRequestor
public QueueRequestor(QueueSession session,
Queue queue)
throws JMSException
Methods
close
public void close() throws JMSException
Send a request and wait for a reply. The temporary queue is used for
replyTo, and only one reply per request is expected.
337
QueueRequestor
Parameters:
message - the message to send.
Returns:
the reply message.
Throws:
JMSException - if a JMS error occurs.
338
QueueSender
QueueSender
public interface QueueSender
extends MessageProducer
WebSphere MQ class: MQQueueSender
java.lang.Object
|
+----com.ibm.mq.jms.MQMessageProducer
|
+----com.ibm.mq.jms.MQQueueSender
Methods
close *
public void close() throws JMSException
339
QueueSender
send
public void send(Message message) throws JMSException
Send a message specifying delivery mode, priority, and time to live to the
queue.
Parameters:
v message - the message to be sent.
v deliveryMode - the delivery mode to use.
v priority - the priority for this message.
v timeToLive - the messages lifetime (in milliseconds).
Throws:
v JMSException - if JMS fails to send the message because of an
internal error.
v MessageFormatException - if a non valid message is specified.
v InvalidDestinationException - if a client uses this method with a
Queue sender with a non valid queue.
send
public void send(Queue queue,
Message message) throws JMSException
340
QueueSender
v InvalidDestinationException - if a client uses this method
with a non valid queue.
send
public void send(Queue queue,
Message message,
int deliveryMode,
int priority,
long timeToLive) throws JMSException
Send a message to the specified queue with delivery mode, priority, and
time to live.
Note: This method can only be used with unidentified QueueSenders.
Parameters:
v queue - the queue that this message should be sent to.
v message - the message to be sent.
v deliveryMode - the delivery mode to use.
v priority - the priority for this message.
v timeToLive - the messages lifetime (in milliseconds).
Throws:
v JMSException - if JMS fails to send the message because
of an internal error.
v MessageFormatException - if a non valid message is
specified.
v InvalidDestinationException - if a client uses this method
with a non valid queue.
341
QueueSession
QueueSession
public interface QueueSession
extends Session
WebSphere MQ class: MQQueueSession
java.lang.Object
|
+----com.ibm.mq.jms.MQSession
|
+----com.ibm.mq.jms.MQQueueSession
Methods
createBrowser
public QueueBrowser createBrowser(Queue queue)
throws JMSException
342
QueueSession
createQueue
public Queue createQueue(java.lang.String queueName)
throws JMSException
Create a Queue given a Queue name. This allows the creation of a queue
with a provider specific name. The string takes a URI format, as described
on page 194.
Note: Clients that depend on this ability are not portable.
Parameters:
queueName - the name of this queue.
Returns:
a Queue with the given name.
Throws:
JMSException - if a session fails to create a queue because of a JMS
error.
createReceiver
public QueueReceiver createReceiver(Queue queue)
throws JMSException
343
QueueSession
Parameters:
queue - the queue to access, or null if this is to be an unidentified
producer.
Throws:
v JMSException - if a session fails to create a sender because of a
JMS error.
v InvalidDestinationException - if a non valid Queue is specified.
createTemporaryQueue
public TemporaryQueue createTemporaryQueue()
throws JMSException
344
Session
Session
public interface Session
extends java.lang.Runnable
Subinterfaces: QueueSession, TopicSession, XAQueueSession, XASession, and
XATopicSession
WebSphere MQ class: MQSession
java.lang.Object
|
+----com.ibm.mq.jms.MQSession
A JMS Session is a single threaded context for producing and consuming messages.
See also: QueueSession, TopicSession, XAQueueSession, XASession, and
XATopicSession
Fields
AUTO_ACKNOWLEDGE
public static final int AUTO_ACKNOWLEDGE
Methods
close
public void close() throws JMSException
345
Session
commit
public void commit() throws JMSException
Commit all messages done in this transaction and release any locks
currently held.
Create a Message. The Message interface is the root interface of all JMS
messages. It holds all the standard message header information. It can be
sent when a message containing only header information is sufficient.
Throws:
JMSException - if JMS fails to create this message because of an
internal error.
346
Session
createObjectMessage
public ObjectMessage createObjectMessage()
throws JMSException
347
Session
getMessageListener
public MessageListener getMessageListener()
throws JMSException
Stop message delivery in this session, and restart sending messages with
the oldest unacknowledged message.
348
Session
rollback
public void rollback() throws JMSException
Roll back any messages done in this transaction and release any locks
currently held.
349
StreamMessage
StreamMessage
public interface StreamMessage
extends Message
WebSphere MQ class: JMSStreamMessage
java.lang.Object
|
+----com.ibm.jms.JMSMessage
|
+----com.ibm.jms.JMSStreamMessage
Methods
readBoolean
public boolean readBoolean() throws JMSException
350
StreamMessage
readBytes
public int readBytes(byte[] value)
throws JMSExceptioneam message.
Read a byte array field from the stream message into the specified byte[]
object (the read buffer). If the buffer size is less than, or equal to, the size
of the data in the message field, an application must make further calls to
this method to retrieve the remainder of the data. Once the first readBytes
call on a byte[] field value has been done, the full value of the field must
be read before it is valid to read the next field. An attempt to read the next
field before that has been done will throw a MessageFormatException.
Parameters:
value - the buffer into which the data is read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no
more data because the end of the byte field has been reached.
Throws:
v JMSException - if JMS fails to read the message because of an
internal JMS error.
v MessageEOFException - if an end of message stream is received.
v MessageFormatException - if this type conversion is not valid.
v MessageNotReadableException - if the message is in write-only
mode.
readChar
public char readChar() throws JMSException
351
StreamMessage
v MessageNotReadableException - if the message is in write-only
mode.
readFloat
public float readFloat() throws JMSException
352
StreamMessage
readObject
public java.lang.Object readObject() throws JMSException
353
StreamMessage
reset
public void reset() throws JMSException
Put the message in read-only mode, and reposition the stream to the
beginning.
Throws:
v JMSException - if JMS fails to reset the message because of an
internal JMS error.
v MessageFormatException - if the message has an not valid
format.
writeBoolean
public void writeBoolean(boolean value) throws JMSException
354
StreamMessage
writeBytes
public void writeBytes(byte[] value,
int offset,
int length) throws JMSException
355
StreamMessage
v MessageNotWriteableException - if the message is in read-only
mode.
writeInt
public void writeInt(int value) throws JMSException
Write a Java object to the stream message. This method only works for
object primitive types (Integer, Double, Long, for example), Strings, and
byte arrays.
Parameters:
value - the Java object to be written.
Throws:
v JMSException - if JMS fails to write the message because of an
internal JMS error.
v MessageNotWriteableException - if the message is in read-only
mode.
v MessageFormatException - if the object is not valid.
356
StreamMessage
writeShort
public void writeShort(short value) throws JMSException
357
TemporaryQueue
TemporaryQueue
public interface TemporaryQueue
extends Queue
WebSphere MQ class: MQTemporaryQueue
java.lang.Object
|
+----com.ibm.mq.jms.MQDestination
|
+----com.ibm.mq.jms.MQQueue
|
+----com.ibm.mq.jms.MQTemporaryQueue
Methods
delete
public void delete() throws JMSException
Delete this temporary queue. If there are still existing senders or receivers
using it, a JMSException will be thrown.
Throws:
JMSException - if JMS implementation fails to delete a
TemporaryQueue because of an internal error.
358
TemporaryTopic
TemporaryTopic
public interface TemporaryTopic
extends Topic
WebSphere MQ class: MQTemporaryTopic
java.lang.Object
|
+----com.ibm.mq.jms.MQDestination
|
+----com.ibm.mq.jms.MQTopic
|
+----com.ibm.mq.jms.MQTemporaryTopic
WebSphere MQ constructor
MQTemporaryTopic
MQTemporaryTopic() throws JMSException
Methods
delete
public void delete() throws JMSException
359
TextMessage
TextMessage
public interface TextMessage
extends Message
WebSphere MQ class: JMSTextMessage
java.lang.Object
|
+----com.ibm.jms.JMSMessage
|
+----com.ibm.jms.JMSTextMessage
Methods
getText
public java.lang.String getText() throws JMSException
Get the string containing this messages data. The default value is null.
Returns:
the String containing the messages data.
Throws:
JMSException - if JMS fails to get the text because of an internal
JMS error.
setText
public void setText(java.lang.String string)
throws JMSException
360
Topic
Topic
public interface Topic
extends Destination
Subinterfaces: TemporaryTopic
WebSphere MQ class: MQTopic
java.lang.Object
|
+----com.ibm.mq.jms.MQDestination
|
+----com.ibm.mq.jms.MQTopic
WebSphere MQ constructor
MQTopic
public MQTopic()
public MQTopic(string URItopic)
See TopicSession.createTopic.
Methods
getBaseTopicName *
public String getBaseTopicName()
361
Topic
getBrokerDurSubQueue *
public String getBrokerDurSubQueue()
Get the name of this topic in URI format. (URI format is described in
Creating topics at runtime on page 212.)
Note: Clients that depend upon the name are not portable.
Returns:
the topic name.
Throws:
JMSException - if JMS implementation for Topic fails to
return the topic name because of an internal error.
setBaseTopicName *
public void setBaseTopicName(String x)
362
Topic
toString
public String toString()
363
TopicConnection
TopicConnection
public interface TopicConnection
extends Connection
Subinterfaces: XATopicConnection
WebSphere MQ class: MQTopicConnection
java.lang.Object
|
+----com.ibm.mq.jms.MQConnection
|
+----com.ibm.mq.jms.MQTopicConnection
Methods
createConnectionConsumer
public ConnectionConsumer createConnectionConsumer
(Topic topic,
java.lang.String messageSelector,
ServerSessionPool sessionPool,
int maxMessages)
throws JMSException
364
TopicConnection
createDurableConnectionConsumer
public ConnectionConsumer createDurableConnectionConsumer
(Topic topic,
java.lang.String subscriptionName
java.lang.String messageSelector,
ServerSessionPool sessionPool,
int maxMessages)
throws JMSException
Create a TopicSession.
365
TopicConnection
Session.DUPS_OK_ACKNOWLEDGE
Indicates whether the consumer or the client will acknowledge
any messages it receives. This parameter will be ignored if the
session is transacted.
Returns:
a newly created topic session.
Throws:
JMSException - if JMS Connection fails to create a session because
of an internal error, or a lack of support for the specific transaction
and acknowledgement mode.
366
TopicConnectionFactory
TopicConnectionFactory
public interface TopicConnectionFactory
extends ConnectionFactory
Subinterfaces: XATopicConnectionFactory
WebSphere MQ class: MQTopicConnectionFactory
java.lang.Object
|
+----com.ibm.mq.jms.MQConnectionFactory
|
+----com.ibm.mq.jms.MQTopicConnectionFactory
WebSphere MQ constructor
MQTopicConnectionFactory
public MQTopicConnectionFactory()
Methods
createTopicConnection
public TopicConnection createTopicConnection()
throws JMSException
367
TopicConnectionFactory
createTopicConnection
public TopicConnection createTopicConnection
(java.lang.String userName,
java.lang.String password)
throws JMSException
368
TopicConnectionFactory
getBrokerQueueManager *
public String getBrokerQueueManager()
getCleanupInterval *
public long getCleanupInterval()
|
|
Returns:
how often the cleanup utility will run, in milliseconds
|
|
getCleanupLevel *
public int getCleanupLevel()
|
|
Returns:
the value of cleanupLevel
getPubAckInterval *
public int getPubAckInterval()
369
TopicConnectionFactory
getStatusRefreshInterval *
public int getStatusRefreshInterval()
370
TopicConnectionFactory
setBrokerSubQueue *
public void setBrokerSubQueue(String x) throws JMSException
setCleanupInterval *
public void setCleanupInterval(long x) throws JMSException
|
|
Parameters:
how often the cleanup utility will run, in milliseconds
|
|
setCleanupLevel *
public void setCleanupLevel(int x) throws JMSException
|
|
|
|
|
|
|
Parameters:
An integer representing one of the valid cleanupLevel values.
These are represented by the constants:
JMSC.MQJMS_CLEANUP_NONE
JMSC.MQJMS_CLEANUP_SAFE
JMSC.MQJMS_CLEANUP_STRONG
JMSC.MQJMS_CLEANUP_AS_PROPERTY
setPubAckInterval *
public void setPubAckInterval(int x)
371
TopicConnectionFactory
setSubscriptionStore *
public void setSubscriptionStore(int x) throws JMSException
372
TopicPublisher
TopicPublisher
public interface TopicPublisher
extends MessageProducer
WebSphere MQ class: MQTopicPublisher
java.lang.Object
|
+----com.ibm.mq.jms.MQMessageProducer
|
+----com.ibm.mq.jms.MQTopicPublisher
Methods
close *
public void close() throws JMSException
Publish a Message to the topic Use the topics default delivery mode, time
to live, and priority.
Parameters:
message - the message to publish
Throws:
v JMSException - if JMS fails to publish the message because of an
internal error.
v MessageFormatException - if a non valid message is specified.
v InvalidDestinationException - if a client uses this method with a
Topic Publisher with a non valid topic.
Chapter 14. JMS interfaces and classes
373
TopicPublisher
publish
public void publish(Message message,
int deliveryMode,
int priority,
long timeToLive) throws JMSException
Publish a Message to the topic specifying delivery mode, priority, and time
to live to the topic.
374
TopicPublisher
publish
public void publish(Topic topic,
Message message,
int deliveryMode,
int priority,
long timeToLive) throws JMSException
375
TopicRequestor
TopicRequestor
public class TopicRequestor
extends java.lang.Object
java.lang.Object
|
+----javax.jms.TopicRequestor
JMS provides this TopicRequestor class to assist with making service requests.
The TopicRequestor constructor is given a non-transacted TopicSession and a
destination Topic. It creates a TemporaryTopic for the responses, and provides a
request() method that sends the request message and waits for its reply. Users are
free to create more sophisticated versions.
Constructors
TopicRequestor
public TopicRequestor(TopicSession session,
Topic topic) throws JMSException
Methods
close
public void close() throws JMSException
376
TopicRequestor
Returns:
the reply message.
Throws:
JMSException - if a JMS error occurs.
377
TopicSession
TopicSession
public interface TopicSession
extends Session
WebSphere MQ class: MQTopicSession
java.lang.Object
|
+----com.ibm.mq.jms.MQSession
|
+----com.ibm.mq.jms.MQTopicSession
WebSphere MQ constructor
MQTopicSession
public MQTopicSession(boolean transacted,
int acknowledgeMode) throws JMSException
See TopicConnection.createTopicSession.
Methods
createDurableSubscriber
public TopicSubscriber createDurableSubscriber
(Topic topic,
java.lang.String name) throws JMSException
See TopicSession.unsubscribe
378
TopicSession
createDurableSubscriber
public TopicSubscriber createDurableSubscriber
(Topic topic,
java.lang.String name,
java.lang.String messageSelector,
boolean noLocal) throws JMSException
|
|
|
Throws:
v JMSException - if a session fails to create a subscriber because of
a JMS error or non valid selector.
v InvalidDestinationException - if the Topic specified is not valid.
v InvalidSelectorException - if the message selector is not valid.
createPublisher
public TopicPublisher createPublisher(Topic topic)
throws JMSException
Throws:
v JMSException - if a session fails to create a publisher because of
a JMS error.
v InvalidDestinationException - if the Topic specified is not valid.
379
TopicSession
createSubscriber
public TopicSubscriber createSubscriber(Topic topic)
throws JMSException
createSubscriber
public TopicSubscriber createSubscriber
(Topic topic,
java.lang.String messageSelector,
boolean noLocal) throws JMSException
createTemporaryTopic
public TemporaryTopic createTemporaryTopic()
throws JMSException
380
TopicSession
createTopic
public Topic createTopic(java.lang.String topicName)
throws JMSException
Create a Topic given a URI format Topic name. (URI format is described in
Creating topics at runtime on page 212.) This allows the creation of a
topic with a provider specific name.
Note: Clients that depend on this ability are not portable.
Parameters:
topicName - the name of this topic.
Returns:
a Topic with the given name.
Throws:
JMSException - if a session fails to create a topic because of
a JMS error.
unsubscribe
public void unsubscribe(java.lang.String name)
throws JMSException
381
TopicSubscriber
TopicSubscriber
public interface TopicSubscriber
extends MessageConsumer
WebSphere MQ class: MQTopicSubscriber
java.lang.Object
|
+----com.ibm.mq.jms.MQMessageConsumer
|
+----com.ibm.mq.jms.MQTopicSubscriber
A client uses a TopicSubscriber for receiving messages that have been published to
a topic. TopicSubscriber is the Pub/Sub variant of a JMS message consumer.
See also: MessageConsumer and TopicSession.createSubscriber
MQTopicSubscriber inherits the following methods from MQMessageConsumer:
close
getMessageListener
receive
receiveNoWait
setMessageListener
Methods
getNoLocal
public boolean getNoLocal() throws JMSException
Get the NoLocal attribute for this TopicSubscriber. The default value for
this attribute is false.
Returns:
set to true if locally published messages are being inhibited.
Throws:
JMSException - if JMS fails to get NoLocal attribute for this topic
subscriber because of an internal error.
getTopic
public Topic getTopic() throws JMSException
382
XAConnection
XAConnection
public interface XAConnection
Subinterfaces: XAQueueConnection and XATopicConnection
WebSphere MQ class: MQXAConnection
java.lang.Object
|
+----com.ibm.mq.jms.MQXAConnection
383
XAConnectionFactory
XAConnectionFactory
public interface XAConnectionFactory
Subinterfaces: XAQueueConnectionFactory and XATopicConnectionFactory
WebSphere MQ class: MQXAConnectionFactory
java.lang.Object
|
+----com.ibm.mq.jms.MQXAConnectionFactory
Some application servers provide support to group JTS-capable resource use into a
distributed transaction. To include JMS transactions in a JTS transaction, an
application server requires a JTS-aware JMS provider. A JMS provider exposes its
JTS support by using a JMS XAConnectionFactory, which an application server
uses to create XASessions. XAConnectionFactories are JMS-administered objects
just like ConnectionFactories. It is expected that application servers use JNDI to
find them.
Refer to Appendix E, JMS JTA/XA interface with WebSphere Application Server
V4 on page 413 for details about how WebSphere MQ JMS uses XA classes.
See also: XAQueueConnectionFactory and XATopicConnectionFactory
384
XAQueueConnection
XAQueueConnection
public interface XAQueueConnection
extends QueueConnection and XAConnection
WebSphere MQ class: MQXAQueueConnection
java.lang.Object
|
+----com.ibm.mq.jms.MQConnection
|
+----com.ibm.mq.jms.MQQueueConnection
|
+----com.ibm.mq.jms.MQXAQueueConnection
Methods
createQueueSession
public QueueSession createQueueSession(boolean transacted,
int acknowledgeMode)
throws JMSException
Create a QueueSession.
Parameters:
v transacted - if true, the session is transacted.
v acknowledgeMode - indicates whether the consumer or the
client will acknowledge any messages it receives. Possible values
are:
Session.AUTO_ACKNOWLEDGE
Session.CLIENT_ACKNOWLEDGE
Session.DUPS_OK_ACKNOWLEDGE
This parameter is ignored if the session is transacted.
Returns:
a newly created queue session (note that this is not an XA queue
session).
Throws:
JMSException - if JMS Connection fails to create a queue session
because of an internal error.
createXAQueueSession
public XAQueueSession createXAQueueSession()
Create an XAQueueSession.
Throws:
JMSException - if JMS Connection fails to create an XA queue
session because of an internal error.
385
XAQueueConnectionFactory
XAQueueConnectionFactory
public interface XAQueueConnectionFactory
extends QueueConnectionFactory and XAConnectionFactory
WebSphere MQ class: MQXAQueueConnectionFactory
java.lang.Object
|
+----com.ibm.mq.jms.MQConnectionFactory
|
+----com.ibm.mq.jms.MQQueueConnectionFactory
|
+----com.ibm.mq.jms.MQXAQueueConnectionFactory
Methods
createXAQueueConnection
public XAQueueConnection createXAQueueConnection()
throws JMSException
386
XAQueueConnectionFactory
Throws:
v JMSException - if the JMS Provider fails to create an XA queue
connection because of an internal error.
v JMSSecurityException - if client authentication fails because of a
non valid user name or password.
387
XAQueueSession
XAQueueSession
public interface XAQueueSession
extends XASession
WebSphere MQ class: MQXAQueueSession
java.lang.Object
|
+----com.ibm.mq.jms.MQXASession
|
+----com.ibm.mq.jms.MQXAQueueSession
Methods
getQueueSession
public QueueSession getQueueSession()
throws JMSException
388
XASession
XASession
public interface XASession
extends Session
Subinterfaces: XAQueueSession and XATopicSession
WebSphere MQ class: MQXASession
java.lang.Object
|
+----com.ibm.mq.jms.MQXASession
Methods
commit
public void commit()
throws JMSException
389
XASession
Specified by:
getTransacted in the Session interface.
Returns:
true - if the session is in transacted mode.
Throws:
JMSException - if JMS fails to return the transaction mode because
of an internal error in the JMS Provider.
getXAResource
public javax.transaction.xa.XAResource getXAResource()
390
XATopicConnection
XATopicConnection
public interface XATopicConnection
extends TopicConnection and XAConnection
WebSphere MQ class: MQXATopicConnection
java.lang.Object
|
+----com.ibm.mq.jms.MQConnection
|
+----com.ibm.mq.jms.MQTopicConnection
|
+----com.ibm.mq.jms.MQXATopicConnection
Methods
createTopicSession
public TopicSession createTopicSession(boolean transacted,
int acknowledgeMode)
throws JMSException
Create a TopicSession.
Specified by:
createTopicSession in interface TopicConnection.
Parameters:
v transacted - if true, the session is transacted.
v acknowledgeMode - one of:
Session.AUTO_ACKNOWLEDGE
Session.CLIENT_ACKNOWLEDGE
Session.DUPS_OK_ACKNOWLEDGE
Indicates whether the consumer or the client will acknowledge
any messages it receives. This parameter will be ignored if the
session is transacted.
Returns:
a newly created topic session (note that this is not an XA topic
session).
Throws:
JMSException - if JMS Connection fails to create a topic session
because of an internal error.
createXATopicSession
public XATopicSession createXATopicSession()
throws JMSException
Create an XATopicSession.
391
XATopicConnection
Throws:
JMSException - if the JMS Connection fails to create an XA topic
session because of an internal error.
392
XATopicConnectionFactory
XATopicConnectionFactory
public interface XATopicConnectionFactory
extends TopicConnectionFactory and XAConnectionFactory
WebSphere MQ class: MQXATopicConnectionFactory
java.lang.Object
|
+----com.ibm.mq.jms.MQConnectionFactory
|
+----com.ibm.mq.jms.MQTopicConnectionFactory
|
+----com.ibm.mq.jms.MQXATopicConnectionFactory
Methods
createXATopicConnection
public XATopicConnection createXATopicConnection()
throws JMSException
393
XATopicConnectionFactory
v JMSException - if the JMS Provider fails to create an XA topic
connection because of an internal error.
v JMSSecurityException - if client authentication fails because of a
non valid user name or password.
394
XATopicSession
XATopicSession
public interface XATopicSession
extends XASession
WebSphere MQ class: MQXATopicSession
java.lang.Object
|
+----com.ibm.mq.jms.MQXASession
|
+----com.ibm.mq.jms.MQXATopicSession
Methods
getTopicSession
public TopicSession getTopicSession()
throws JMSException
395
396
Part 4. Appendixes
397
398
BROKERCCDSUBQ
brokerCCDurSubQueue
BROKERCCSUBQ
brokerCCSubQueue
BROKERCONQ
brokerControlQueue
BROKERDURSUBQ
brokerDurSubQueue
BROKERPUBQ
brokerPubQueue
BROKERQMGR
brokerQueueManager
BROKERSUBQ
brokerSubQueue
BROKERVER
brokerVersion
CCSID
CCSID
CHANNEL
channel
|
|
|
|
CLEANUP
cleanupLevel
CLEANUPINT
cleanupInterval
CLIENTID
clientId
DESCRIPTION
description
ENCODING
encoding
EXPIRY
expiry
HOSTNAME
hostName
MSGBATCHSZ
msgBatchSize
MSGRETENTION
Tool property
values
V1
V2
JMSC.MQJMS_BROKER_V1
JMSC.MQJMS_BROKER_V2
NONE
SAFE
STRONG
ASPROP
JMSC.MQJMS_CLEANUP_NONE
JMSC.MQJMS_CLEANUP_SAFE
JMSC.MQJMS_CLEANUP_STRONG
JMSC.MQJMS_CLEANUP_AS_PROPERTY
APP
UNLIM
JMSC.MQJMS_EXP_APP
JMSC.MQJMS_EXP_UNLIMITED
messageRetention
YES
NO
JMSC.MQJMS_MRET_YES
JMSC.MQJMS_MRET_NO
PERSISTENCE
persistence
APP
QDEF
PERS
NON
JMSC.MQJMS_PER_APP
JMSC.MQJMS_PER_QDEF
JMSC.MQJMS_PER_PER
JMSC.MQJMS_PER_NON
POLLINGINT
pollingInterval
PORT
port
399
Properties
Table 37. Comparison of representations of property values within the administration tool and within
programs. (continued)
Property
PRIORITY
priority
PUBACKINT
pubAckInterval
QUEUE
baseQueueName
QMANAGER
queueManager*
RECEXIT
receiveExit
RECEXITINIT
receiveExitInit
SECEXIT
securityExit
SECEXITINIT
securityExitInit
SENDEXIT
sendExit
SENDEXITINIT
sendExitInit
SSLCIPHERSUITE
sslCipherSuite
SSLCRL
sslCertStores
SSLPEERNAME
sslPeerName
STATREFRESHINT
statusRefreshInterval
SYNCPOINTALLGETS
syncpointAllGets
TARGCLIENT
targetClient
TEMPMODEL
temporaryModel
TOPIC
baseTopicName
TRANSPORT
transportType
USECONNPOOLING
useConnectionPooling
Tool property
values
APP
QDEF
JMSC.MQJMS_PRI_APP
JMSC.MQJMS_PRI_QDEF
JMS
MQ
JMSC.MQJMS_CLIENT_JMS_COMPLIANT
JMSC.MQJMS_CLIENT_NONJMS_MQ
BIND
CLIENT
DIRECT
JMSC.MQJMS_TP_BINDINGS_MQ
JMSC.MQJMS_TP_CLIENT_MQ_TCPIP
JMSC.MQJMS_TP_DIRECT_TCPIP
400
Use
Cleanup.bat
DefaultConfiguration
formatLog.bat
IVTRun.bat
IVTTidy.bat
IVTSetup.bat
JMSAdmin.bat
JMSAdmin.config
postcard.bat
PSIVTRun.bat
PSReportDump.class
runjms.bat
Note: On UNIX systems, the extension .bat is omitted from the filenames.
401
Scripts
402
If no errors occur, your server is properly configured to store Java objects and you
can proceed to store JMS objects. However, if your LDAP server contains older
schema definitions (for example, from an earlier draft of RFC 2713 such as the
now-obsolete draft-ryan-java-schema-00 and draft-ryan-java-schema-01
specifications), you should update them with those presented here.
If a SchemaViolationException occurs, or if the message Unable to bind to object
is returned, your server is not properly configured. Either your server is not
configured to store Java objects, or permissions on the objects are not correct, or
the provided suffix or context has not been set up. The following information
should help you with the schema configuration part of your server setup.
403
Attribute definitions
Attribute definitions
Table 39. Attribute settings for javaCodebase
Attribute
Value
1.3.6.1.4.1.42.2.27.4.1.7
Syntax
Maximum length
2048
Single/multi-valued
Multi-valued
User modifiable?
Yes
Matching rules
caseExactIA5Match
Access class
normal
Usage
userApplications
Description
Value
1.3.6.1.4.1.42.2.27.4.1.6
Syntax
Maximum length
2048
Single/multi-valued
Single-valued
User modifiable?
Yes
Matching rules
caseExactMatch
Access class
normal
Usage
userApplications
Description
404
Attribute
Value
1.3.6.1.4.1.42.2.27.4.1.13
Syntax
Maximum length
2048
Single/multi-valued
Multi-valued
User modifiable?
Yes
Matching rules
caseExactMatch
Access class
normal
Usage
userApplications
Description
Attribute definitions
Table 42. Attribute settings for javaFactory
Attribute
Value
1.3.6.1.4.1.42.2.27.4.1.10
Syntax
Maximum length
2048
Single/multi-valued
Single-valued
User modifiable?
Yes
Matching rules
caseExactMatch
Access class
normal
Usage
userApplications
Description
Value
1.3.6.1.4.1.42.2.27.4.1.11
Syntax
Maximum length
2048
Single/multi-valued
Multi-valued
User modifiable?
Yes
Matching rules
caseExactMatch
Access class
normal
Usage
userApplications
Description
Value
1.3.6.1.4.1.42.2.27.4.1.8
Syntax
Single/multi-valued
Single-valued
User modifiable?
Yes
Access class
normal
Usage
userApplications
Description
objectClass definitions
Table 45. objectClass definition for javaSerializedObject
Definition
Value
1.3.6.1.4.1.42.2.27.4.2.5
Extends/superior
javaObject
Type
AUXILIARY
javaSerializedData
405
objectClass definitions
Table 46. objectClass definition for javaObject
Definition
Value
1.3.6.1.4.1.42.2.27.4.2.4
Extends/superior
top
Type
ABSTRACT
javaClassName
Value
1.3.6.1.4.1.42.2.27.4.2.1
Extends/superior
top
Type
STRUCTURAL
cn
Value
1.3.6.1.4.1.42.2.27.4.2.7
Extends/superior
javaObject
Type
AUXILIARY
javaReferenceAddress javaFactory
406
407
408
When this message flow is deployed and the broker is started, from the
JMS applications perspective the WebSphere MQ Integrator V2 broker
409
This URI form allows an application to set the mcd to a domain that is not one of
the standard jms_xxxx values; for example, to domain mrm. It also allows the
application to set any or all of the mcd set, type and format fields if desired.
The string argument to setJMSType is interpreted as follows:
410
411
412
Administered objects
JMS uses administered objects to encapsulate vendor-specific information. This
minimizes the impact of vendor-specific details on end-user applications.
Administered objects are stored in a JNDI namespace, and can be retrieved and
used in a portable manner without knowledge of the vendor-specific contents.
For standalone use, WebSphere MQ JMS provides the following classes:
v MQQueueConnectionFactory
v MQQueue
v MQTopicConnectionFactory
v MQTopic
WebSphere Application Server provides an additional pair of administered objects
so that WebSphere MQ JMS can integrate with WebSphere Application Server:
v JMSWrapXAQueueConnectionFactory
v JMSWrapXATopicConnectionFactory
You use these objects in exactly the same way as the MQQueueConnectionFactory
and MQTopicConnectionFactory. However, behind the scenes they use the XA
versions of the JMS classes, and enlist the WebSphere MQ JMS XAResource in the
WebSphere Application Server transaction.
413
These new types use the same properties as the equivalent QCF or TCF types,
except that only the BIND transport type is allowed (and therefore, client
properties cannot be configured). For details, see Administering JMS objects on
page 43.
The objects can be cast to, and used as, the generic JMS interfaces. Normally, there
is no need to program to the WebSphere MQ specific classes in the application
code.
Samples
There are three samples that illustrate the basics of using WebSphere MQ JMS with
WebSphere Application Server Advanced Edition. These are in subdirectories of
MQ_samples_dir/ws, where MQ_samples_dir is the samples directory for WebSphere
MQ JMS. See Table 3 on page 8 to find where this is.
|
|
|
|
414
v Sample1 demonstrates a simple put and get for a message in a queue by using
container-managed transactions.
v Sample2 demonstrates a simple put and get for a message in a queue by using
bean-managed transactions.
v Sample3 illustrates the use of the publish/subscribe API.
For details about how to build and deploy the EJB beans, please refer to the
WebSphere Application Server documentation.
The readme.txt files in each sample directory include example output from each
EJB bean. The scripts provided assume that a default queue manager is available
on the local machine. If your installation varies from the default, you can edit these
scripts as required.
Sample1
Sample1EJB.java, in the sample1 directory, defines two methods that use JMS:
v putMessage() sends a TextMessage to a queue, and returns the MessageID of the
sent message
v getMessage() reads the message with the specified MessageID back from the
queue
Before you run the sample, you must store two administered objects in the
WebSphere Application Server JNDI namespace:
QCF1 a WebSphere Application Server-specific queue connection factory
Q1
a queue
The bean must be deployed with the getMessage and putMessage methods marked
as TX_REQUIRED. This ensures that the container starts a transaction before
entering each method, and commits the transaction when the method completes.
Within the methods, you do not need any application code that relates to the
transactional state. However, remember that the message sent from putMessage
occurs under syncpoint, and will not become available until the transaction is
committed.
In the sample1 directory, there is a simple client program, Sample1Client.java, to
call the EJB bean. There is also a script, runClient, to simplify running this
program.
415
Sample2
Sample2EJB.java, in the sample2 directory, performs the same task as sample1, and
requires the same administered objects. Unlike sample1, sample2 uses
bean-managed transactions to control the transactional boundaries.
If you have not already run sample1, ensure that you set up the administered
objects QCF1 and Q1, as described in Sample1 on page 415.
The putMessage methods and getMessage methods start by obtaining an instance
of UserTransaction. They use this instance to create a transaction via the
UserTransaction.begin() method. After that, the main body of the code is the same
as sample1 until the end of each method. At the end of each method, the
transaction is completed by the UserTransaction.commit() call.
In the sample2 directory, there is a simple client program, Sample2Client.java, to
call the EJB bean. There is also a script, runClient, to simplify running this
program. You can use these in the same way as described for Sample1 on
page 415.
Sample3
Sample3EJB.java, in the sample3 directory, demonstrates the use of the
publish/subscribe API with WebSphere Application Server. Publishing a message is
very similar to the point to point case. However, there are differences when
receiving messages via a TopicSubscriber.
Publish/subscribe programs commonly use nondurable subscribers. These
nondurable subscribers exist only for the lifetime of their owning sessions (or less
if the subscriber is closed explicitly). Also, they can receive messages from the
broker only during that lifetime.
To convert sample1 to publish/subscribe, you might replace the QueueSender in
putMessage with a TopicPublisher, and the QueueReceiver in getMessage with a
nondurable TopicSubscriber. However, this would fail, because when the message
is sent, the broker would not know of any subscribers to the topic. Therefore, the
message would be discarded.
The solution is to create a durable subscriber before the message is published.
Durable subscribers persist as a deliverable end-point beyond the lifetime of the
session. Therefore, the message is available for retrieval during the call to
getMessage().
The EJB bean includes two additional methods:
v createSubscription creates a durable subscription
416
If you have already run admin.scp to set up objects for sample1 or sample2, there
will be error messages when you run admin.scp for sample3. (These occur when
you attempt to create the jms and Samples sub-contexts.) You can safely ignore
these error messages.
Also, before you run sample3, ensure that the WebSphere MQ publish/subscribe
broker (SupportPac MA0C) is installed and running.
In the sample3 directory, there is a simple client program, Sample3Client.java, to
call the EJB bean. There is also a script, runClient, to simplify running this
program. You can use these in the same way as described for Sample1 on
page 415.
417
418
Notes:
1. You may need to restart VisualAge for Java if you get the error message
Unknown Java Error after repeated tests.
Copyright IBM Corp. 1997, 2002
419
For appletviewer:
Find the policy file for your JDK and make the same changes as for IBM
VisualAge for Java. For example, in the IBM Developer Kit for Windows,
Java Technology Edition, Version 1.3, the java.policy file is found in the
directory <jdk_install_dir>\jre\lib\security, where
<jdk_install_dir> is the directory where the Developer Kit was
installed.
For a web browser:
To achieve consistent behavior for applets within different web browsers
use the Sun Java plug-in.
1. Install the Sun Java plug-in 1.3.01 or later.
From this level, Netscape 6 is also supported.
2. Make the same changes to the java.policy file as listed above.
The policy file is found in <java_plugin_install_dir>\lib\security.
3. Make sure that your HTML applet tags are changed to run with the
plug-in.
Download and run the Sun HTML Converter v1.3 to make the
necessary changes.
420
2. Using FTP binary mode, upload the file ma1g.tar.Z from your workstation to
the HFS directory /u/joe/mqm.
421
MQSimpleConnectionManager
MQPoolServicesEventListener
MQConnectionManager
ManagedConnection
ManagedConnectionFactory
ManagedConnectionMetaData
v Methods
MQEnvironment.getDefaultConnectionManager()
MQEnvironment.setDefaultConnectionManager()
MQEnvironment.addConnectionPoolToken()
MQEnvironment.removeConnectionPoolToken()
The six MQQueueManager constructors which allow a ConnectionManager or
MQConnectionManager to be specified.
Attempting to use these classes, interfaces or methods will result in compile-time
errors or run-time exceptions.
422
423
424
|
|
|
|
|
|
|
|
|
The following table lists the CipherSpecs supported by WebSphere MQ, and their
associated CipherSuite names. The CipherSpec name should be specified in the
SSLCIPH property of the SVRCONN channel on the queue manager. The
CipherSuite name should be specified in MQEnvironment.sslCipherSuite or
MQC.SSL_CIPHER_SUITE_PROPERTY of WebSphere MQ base Java, or using the
setSSLCipherSuite() method of MQConnectionFactory in JMS, or using the
SSLCIPHERSUITE (SCPHS) property from JMSAdmin. The set of supported
CipherSuites will vary between JSSE providers; those CipherSuites not supported
by the IBM implementation of JSSE are marked with an asterisk.
CipherSpec
CipherSuite
DES_SHA_EXPORT
SSL_RSA_WITH_DES_CBC_SHA
DES_SHA_EXPORT1024
SSL_RSA_EXPORT1024_WITH_DES_CBC_SHA *
NULL_MD5
SSL_RSA_WITH_NULL_MD5
NULL_SHA
SSL_RSA_WITH_NULL_SHA
RC2_MD5_EXPORT
SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5
RC4_56_SHA_EXPORT1024
SSL_RSA_EXPORT1024_WITH_RC4_56_SHA *
RC4_MD5_US
SSL_RSA_WITH_RC4_128_MD5
RC4_MD5_EXPORT
SSL_RSA_EXPORT_WITH_RC4_40_MD5
RC4_SHA_US
SSL_RSA_WITH_RC4_128_SHA
TRIPLE_DES_SHA_US
SSL_RSA_WITH_3DES_EDE_CBC_SHA
425
426
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| MQJMS0000 Method {0} has been invoked at an
illegal or inappropriate time or if the
|
provider is not in an appropriate state
|
for the requested operation.
|
| Explanation: The normal reason for this exception is
| that the SSL certificate stores have not been defined. {0}
| identifies the method that has caused the problem.
| User Response: See Using Secure Sockets Layer
| (SSL) on page 199 for more information.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
427
MQJMS1000 MQJMS1020
|
|
|
|
|
|
|
|
| MQJMS1001 Unknown acknowledgement mode {0}.
| Explanation: Invalid or no parameter {0} set for
| acknowledgement mode on the session.
| User Response: See Session on page 345 for the
| possible values for acknowledgement mode.
|
|
|
|
|
|
|
| MQJMS1005 Unhandled state transition from {0} to
{1}.
|
| Explanation: The state transition is not valid, see log
| for more information.
| User Response: Check the linked WebSphere MQ
| exception reason and completion code.
|
| MQJMS1006 Invalid value for {0}: {1}
| Explanation: Invalid value {1} for property {0}.
| User Response: Check the linked WebSphere MQ
| exception reason and completion code. See Table 11 on
| page 46 for a list of valid values for this property.
|
| MQJMS1008 Unknown value of transportType: {0}.
| Explanation: The value given for transportType could
| not be used. {0} shows the invalid value.
| User Response: See Table 11 on page 46 for a list of
| valid values for this property.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MQJMS1021 MQJMS1039
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| MQJMS1026 ExceptionListener threw exception: {0}.
| User Response: Check linked exceptions for further
| information.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| MQJMS1031 An internal error has occurred. Please
contact your system administrator.
|
| Explanation: Internal Error.
| User Response: Contact your IBM representative.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
Appendix I. JMS exception messages
429
MQJMS1040 MQJMS1055
|
|
|
|
|
|
| MQJMS1041 Failed to find system property {0}.
| Explanation: The system property specified in {0} does
| not exist or was not found in the applications
| classpath.
| User Response: Check the classpath settings and the
| product installation.
|
|
|
|
|
|
|
|
|
| MQJMS1043 JNDI failed due to {0}.
| Explanation: {0} gives further information.
| User Response: Check settings for LDAP, JNDI, and
| in the JMSAdmin.config file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| MQJMS1045 Number outside of range for double
precision S/390 Float {0}.
|
| Explanation: This is a z/OS & OS/390 specific error.
|
| MQJMS1046 The character set {0} is not supported.
| Explanation: An attempt was made to send or receive
| a map message, stream message or text message whose
| body is encoded using a character set not supported by
| the JVM. In the case of text messages, this exception
| may be thrown when the body of the message is first
| queried, rather than at receive time.
| User Response: Only set character encoding on a
| message to values known to be available to the
| receiving application.
|
430
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MQJMS1056 MQJMS1073
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
Appendix I. JMS exception messages
431
MQJMS1074 MQJMS1087
|
| MQJMS1074 Unable to process null message.
| Explanation: Internal error in WebSphere MQ JMS.
| User Response: Contact your IBM representative.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432
MQJMS1088 MQJMS2013
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| MQJMS2012 XACLOSE failed.
| Explanation: See linked XAException for more details.
|
|
|
|
|
|
433
MQJMS3000 MQJMS3020
| User Response: Check that the user IDs used by
| WebSphere MQ are all assigned to the relevant groups
| and given appropriate user permissions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| MQJMS3014 Failed to open subscriber queue {0}.
| User Response: See linked exception for more
| information.
|
| MQJMS3005 Publish/Subscribe failed due to {0}.
| Explanation: General error: {0} shows the reason.
| User Response: Check the linked WebSphere MQ
| Exception reason and completion codes for more
| information. It is possible that the broker and queue
| manager versions are incompatible.
|
| MQJMS3006 Topic reference is null.
| Explanation: Topic supplied to a publisher is null.
| User Response: Use non-null values.
|
| MQJMS3008 Failed to build command {0}.
| Explanation: Broker message command parameters
| incorrect.
| User Response: Check linked exception for cause.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| MQJMS3020 TemporaryTopic out of scope.
| Explanation: The current connection ID does not
| match the connection that created the temporary topic.
||
|
434
MQJMS3021 MQJMS3040
|
| MQJMS3021 Invalid subscriber queue prefix: {0}.
| Explanation: The name specified is not valid. It must
| begin with SYSTEM.JMS.D for durable subscriptions or
| SYSTEM.JMS.ND for non-durable subscriptions.
| User Response: See Chapter 11, Programming
| publish/subscribe applications on page 203 for naming
| conventions.
|
| MQJMS3022 Durable re-subscribe must use same
subscriber queue; specified: {0}, original:
|
{1}.
|
| Explanation: {0} and {1} show the differing queue
| names. Unable to get a subscription due to wrong
| queue manager or queue.
| User Response: Check settings.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| MQJMS3026 QueueSender is closed.
| User Response: Open or re-open the queue sender if
| required.
|
| MQJMS3027 Local transactions not allowed with XA
sessions.
|
| Explanation: Unexpected error.
| User Response: Contact your IBM representative.
|
| MQJMS3028 TopicPublisher is closed.
| User Response: Open or reopen the topic publisher if
| required.
|
|
|
|
|
|
|
|
|
|
|
|
|
| MQJMS3033 QueueReceiver is closed.
| User Response: Open or reopen the receiver.
|
| MQJMS3034 TopicSubscriber is closed.
| User Response: Open or reopen the TopicSubscriber.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
Appendix I. JMS exception messages
435
MQJMS3042 MQJMS4130
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
|
| MQJMS4106 Object is not a WebSphere MQ JMS
administered object.
|
| User Response: See Chapter 5, Using the WebSphere
| MQ JMS administration tool on page 39.
|
| MQJMS4111 Unable to create context.
| Explanation: Administration service failed.
| User Response: Check LDAP and JNDI settings.
|
| MQJMS4112 Unable to create a valid object, please
check the parameters supplied.
|
| Explanation: Consistency check failed.
| User Response: Contact your IBM representative.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
MQJMS4131 MQJMS6061
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| MQJMS4137 Unable to create a WebSphere MQ
specific class. The WebSphere MQ
|
classes may not have been installed or
|
added to the classpath.
|
| User Response: Check WebSphere Application Server
| installation and classpath variable.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| MQJMS6059 An exception occurred while loading the
minimal client security implementation.
|
| User Response: Contact your IBM representative.
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
Appendix I. JMS exception messages
437
MQJMS6062 MQJMS6085
|
| MQJMS6062 EOF was encountered while receiving
data in the minimal client.
|
| User Response: Contact your IBM representative.
|
| MQJMS6063 The broker indicated an error on the
minimal client connection.
|
| User Response: Refer to JMS or broker
| documentation. Contact your IBM representative.
|
|
|
|
|
|
|
|
|
| MQJMS6065 An illegal value was encountered for a
field, value = {0}.
|
| Explanation: {0} shows the illegal value.
| User Response: See Table 37 on page 399 for a list of
| properties and their possible values.
|
| MQJMS6066 An unexpected internal error occurred in
the minimal client.
|
| Explanation: Internal problem.
| User Response: Contact your IBM representative.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| MQJMS6081 An attempt was made to read from a
Stream message before a previous read
|
has completed.
|
| Explanation: Internal error.
| User Response: Contact your IBM representative.
|
|
|
|
|
|
|
|
| MQJMS6085 No ExceptionListener has been set.
| User Response: Create an ExceptionListener.
||
|
438
MQJMS6088 MQJMS6121
|
| MQJMS6088 The client-side connection monitor is
terminating.
|
| User Response: Restart the connection.
|
|
|
|
|
|
|
|
|
|
|
| MQJMS6091 An IOException occurred when starting
or stopping delivery on the connection,
|
exception = {0}.
|
| Explanation: Parameter {0} gives details of the
| exception.
| User Response: Restart the connection.
|
|
|
|
|
|
|
| MQJMS6096 A JMSPriority level of {0} is outside the
range specified in JMS.
|
| Explanation: Parameter {0} gives the value that is in
| error.
| User Response: See Table 37 on page 399 for valid
| values.
|
| MQJMS6097 The specified JMSMessageID, {0}, is
invalid.
|
| Explanation: Incorrect syntax was used to specify a
| message ID in Message.setJMSMessageID. The correct
| syntax is ID:[0-9]+.
| User Response: Check parameters. See Chapter 12,
| JMS messages on page 225 for more information on
| message IDs.
|
|
|
|
|
|
|
|
| MQJMS6106 An exception occurred when initializing
parameter {0}, exception {1}.
|
| Explanation: {0} identifies the failing parameter and
| {1} the caught exception.
| User Response: Contact your IBM representative.
|
| MQJMS6115 An exception occurred while creating
the TopicConnection, exception {0}.
|
| Explanation: {0} gives details of the exception.
| User Response: Contact your IBM representative.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
Appendix I. JMS exception messages
439
MQJMS6122 MQJMS6312
|
| MQJMS6122 An exception occurred when creating
subscription to {0}, {1}.
|
| Explanation: An invalid subject or query syntax was
| used in the creation of a subscriber, resulting in an
| exception. {0} is the topic name, and {1} is the caught
| exception.
| User Response: See Chapter 11, Programming
| publish/subscribe applications on page 203 and the
| broker documentation for more information.
|
| MQJMS6232 While creating a TopicSubscriber,
attempting to add the subscription to
|
the matching engine resulted in
|
exception: {0}.
|
| Explanation: {0} gives details of the exception.
| User Response: See Chapter 11, Programming
| publish/subscribe applications on page 203 and the
| broker documentation for more information.
|
|
|
|
|
|
|
|
|
| MQJMS6235 An attempt was made to remove an
object with a Topic {0} from the
|
matching engine, but it did not have a
|
cache entry: {1}.
|
| Explanation: Internal error.
| User Response: Contact your IBM representative.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
|
| MQJMS6247 The Topic segment separator {0} appears
in an incorrect position.
|
| Explanation: A subscription Topic separator was used
| incorrectly. {0} shows the bad separator.
| User Response: See Using topics on page 210 for
| more information.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Appendix J. Notices
This information was developed for products and services offered in the United
States. IBM may not offer the products, services, or features discussed in this
information in other countries. Consult your local IBM representative for
information on the products and services currently available in your area. Any
reference to an IBM product, program, or service is not intended to state or imply
that only that IBM product, program, or service may be used. Any functionally
equivalent product, program, or service that does not infringe any IBM intellectual
property right may be used instead. However, it is the users responsibility to
evaluate and verify the operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter
described in this information. The furnishing of this information does not give you
any license to these patents. You can send license inquiries, in writing, to:
IBM Director of Licensing
IBM Corporation
North Castle Drive
Armonk, NY 10504-1785
U.S.A.
For license inquiries regarding double-byte (DBCS) information, contact the IBM
Intellectual Property Department in your country or send inquiries, in writing, to:
IBM World Trade Asia Corporation
Licensing
2-31 Roppongi 3-chome, Minato-ku
Tokyo 106, Japan
The following paragraph does not apply to the United Kingdom or any other
country where such provisions are inconsistent with local law:
INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS
PUBLICATION AS IS WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS
FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or
implied warranties in certain transactions, therefore this statement may not apply
to you.
This information could include technical inaccuracies or typographical errors.
Changes are periodically made to the information herein; these changes will be
incorporated in new editions of the information. IBM may make improvements
and/or changes in the product(s) and/or the program(s) described in this
information at any time without notice.
Any references in this information to non-IBM Web sites are provided for
convenience only and do not in any manner serve as an endorsement of those Web
sites. The materials at those Web sites are not part of the materials for this IBM
product and use of those Web sites is at your own risk.
IBM may use or distribute any of the information you supply in any way it
believes appropriate without incurring any obligation to you.
441
Notices
Licensees of this program who wish to have information about it for the purpose
of enabling: (i) the exchange of information between independently created
programs and other programs (including this one) and (ii) the mutual use of the
information which has been exchanged, should contact:
IBM United Kingdom Laboratories,
Mail Point 151,
Hursley Park,
Winchester,
Hampshire,
England
SO21 2JN.
Such information may be available, subject to appropriate terms and conditions,
including in some cases, payment of a fee.
The licensed program described in this information and all licensed material
available for it are provided by IBM under terms of the IBM Customer Agreement,
IBM International Programming License Agreement, or any equivalent agreement
between us.
Information concerning non-IBM products was obtained from the suppliers of
those products, their published announcements or other publicly available sources.
IBM has not tested those products and cannot confirm the accuracy of
performance, compatibility or any other claims related to non-IBM products.
Questions on the capabilities of non-IBM products should be addressed to the
suppliers of those products.
COPYRIGHT LICENSE:
This information contains sample application programs in source language, which
illustrate programming techniques on various operating platforms. You may copy,
modify, and distribute these sample programs in any form without payment to
IBM, for the purposes of developing, using, marketing or distributing application
programs conforming to the application programming interface for the operating
platform for which the sample programs are written. These examples have not
been thoroughly tested under all conditions. IBM, therefore, cannot guarantee or
imply reliability, serviceability, or function of these programs. You may copy,
modify, and distribute these sample programs in any form without payment to
IBM for the purposes of developing, using, marketing, or distributing application
programs conforming to IBMs application programming interfaces.
Trademarks
The following terms are trademarks of International Business Machines
Corporation in the United States, or other countries, or both:
AIX
CICS
iSeries
MVS/ESA
OS/400
System/390
VSE/ESA
zSeries
442
AS/400
IBM
Language Environment
OS/2
SecureWay
S/390
WebSphere
BookManager
IBMLink
MQSeries
OS/390
SupportPac
VisualAge
z/OS
Notices
Java, HotJava, JDK, and all Java-based trademarks and logos are trademarks or
registered trademarks of Sun Microsystems, Inc. in the United States, other
countries, or both.
Microsoft, Windows, and Windows NT are trademarks of Microsoft Corporation in
the United States, other countries, or both.
UNIX is a registered trademark of The Open Group in the United States and other
countries.
Other company, product, and service names may be trademarks or service marks
of others.
Appendix J. Notices
443
444
Index
A
445
D
default connection pool 73
multiple components 75
default trace and log output locations 35
DEFINE (administration verb) 43
defining connection type 62
defining transport 192
definition, LDAP schema 403
DELETE (administration verb) 43
DeliveryMode interface 292
dependencies, property 51
DESCRIPTION object property 48, 401
Destination interface 293
differences between applets and
applications 61
differences due to environment 423
directories, installation 8
disconnecting from a queue manager 68
DISPLAY (administration verb) 43
disposition options, message 126, 247
distribution lists
platform dependency 92
durable subscribers 214
446
E
ENCODING object property 52
END (administration verb) 43
environment dependencies 89
functions not with all platforms 92
distribution lists 92
MQGetMessageOptions fields 92
MQMD fields 93
MQPutMessageOptions fields 93
MQQueueManager begin()
method 92
MQQueueManager constructor 92
restrictions and variations 90
MQCNO_FASTPATH_BINDING 90
MQGMO_* values 90
MQPMO_* values 90
MQPMRF_* values 90
MQRO_* values 91
z/OS & OS/390 91
environment differences 423
environment variables 8
configuring 23
error
conditions for object creation 54
handling 70
logging 36
recovery, IVT 31
recovery, PSIVT 35
runtime, handling 198
error messages 16
LDAP server 403
example code 62
exception listener 198
exception messages, JMS 427
exception report options, message 126,
247
ExceptionListener interface 295
exceptions
JMS 198
WebSphere MQ 198
exit string properties 52
expiration report options, message 126
EXPIRY object property 48, 401
extra function provided over WebSphere
MQ Java 3
F
factories, creating at runtime 191
formatLog utility 39, 401
fscontext.jar 7
function, extra provided over WebSphere
MQ Java 3
functions, Application Server
Facilities 243
G
getting started 3
H
handling
errors 70
JMS runtime errors 198
handling (continued)
messages 69
headers, message 225
HOSTNAME object property 48, 401
I
import statements 207
INITIAL_CONTEXT_FACTORY
property 40, 41
inquire and set 71
installation
directories 8
Installation Verification Test program
for publish/subscribe (PSIVT) 32
IVT error recovery 31
PSIVT error recovery 35
setup 23
verifying 17
Installation Verification Test program
(IVT) 28
installing
WebSphere MQ classes for Java 7
WebSphere MQ classes for Java
Message Service 7
interface, programming 58
interfaces
JMS 189, 261
WebSphere MQ 189
introduction
for programmers 57
WebSphere MQ classes for Java 3
WebSphere MQ classes for Java
Message Service 3
IVT (Installation Verification Test
program) 28
IVTrun utility 401
IVTRun utility 29, 30, 34
IVTSetup utility 30, 401
IVTTidy utility 31, 401
J
J2EE connector architecture 74
JAAS (Java Authentication and
Authorization Service) 74, 173
jar files 7
Java 2 Platform Enterprise Edition
(J2EE) 74
Java 2 Security Manager, running
applications under 10
Java Authentication and Authorization
Service (JAAS) 74, 173
Java classes 59
See classes, WebSphere MQ classes for
Java
Java Development Kit (JDK) 58
Java interface, advantages 57
Java Transaction API (JTA) 389, 413
javaClassName
LDAP attribute setting 404
javaClassNames
LDAP attribute setting 404
javaCodebase
LDAP attribute setting 404
javaContainer
LDAP objectClass definition 406
javaFactory
LDAP attribute setting 405
javaNamingReference
LDAP objectClass definition 406
javaObject
LDAP objectClass definition 406
javaReferenceAddress
LDAP attribute setting 405
javaSerializedData
LDAP attribute setting 405
javaSerializedObject
LDAP objectClass definition 405
javax.jms package 261
JDBC coordination 79
JDK (Java Development Kit) 58
JMS
administered objects 190
benefits 3
classes 261
exception listener 198
exceptions 198
reference 427
interfaces 189, 261
introduction 3
mapping of fields at send or
publish 236
mapping with MQMD 233
message types 195
messages 225
model 189
objects for publish/subscribe 207
objects, administering 43
objects, creating 45
objects, properties 46
programs, writing 189
resources, closing in
publish/subscribe mode 209
JMS exception messages 427
JMS JTA/XA Interface 413
JMS Postcard
accessibility 22
changing appearance 22
changing browser for help 22
default configuration 20
font and color settings 22
how it works 20
interoperability with other Postcard
applications 21
receiving messages 20
sending a postcard 18
sending messages 21
signon 18
advanced options 18
starting 17
tidying up after use 21
using with one queue manager 18
using with two queue managers 19
jms.jar 7
JMSAdmin configuration file 40, 41
JMSAdmin utility 39, 401
JMSAdmin.config file 39
JMSBytesMessage class 266
JMSCorrelationID header field 225
JMSMapMessage class 296
JMSMessage class 305
L
LDAP naming considerations 45
LDAP schema definition 403
LDAP server 30
attribute settings
javaClassName 404
javaClassNames 404
javaCodebase 404
javaFactory 405
javaReferenceAddress 405
javaSerializedData 405
configuration 403
error messages 403
iSeries OS/400 V4R5 Schema
Modification 407
Microsoft Active Directory 406
Netscape Directory 406
objectClass definitions
javaContainer 406
javaNamingReference 406
javaObject 406
javaSerializedObject 405
schema 403
Sun Microsystems Schema
Modification Applications 407
ldap.jar 7
library, Java classes 59
listener, JMS exception 198
Load1.java 253
Load2.java 256
local publications, suppressing 214
log file
converting 39
default output location 35
logging errors 36
LoggingMessageListenerFactory.java 256
M
MA1G, SupportPac
special considerations for 421
ManagedConnection 180
ManagedConnectionFactory 183
ManagedConnectionMetaData 185
manipulating subcontexts 43
map message 225
MapMessage
interface 296
type 196
mapping properties between admin. tool
and programs 399
mcd folder 410
message
body 225
delivery, asynchronous 197
error 16
handling 69
headers 225
message body 241
properties 225
selectors 197, 225
selectors and SQL 226
selectors in publish/subscribe
mode 214
sending 193
types 195, 225
Message interface 305
MessageConsumer interface 189, 319
MessageListener interface 321
MessageListenerFactory.java 252
MessageProducer interface 189, 322
MessageProducer object 193
messages
JMS 225
mapping between JMS and
WebSphere MQ 229
poison 246
publishing 209
receiving 196
receiving in publish/subscribe
mode 209
selecting 197, 225
model, JMS 189
MOVE (administration verb) 43
MQC 171
MQChannelDefinition 96
MQChannelExit 98
MQCNO_FASTPATH_BINDING
variations by environment 90
MQConnection class 279
MQConnectionConsumer class 243, 282
MQConnectionFactory class 283
MQConnectionManager 173
MQConnectionMetaData class 290
MQDeliveryMode class 292
MQDestination class 293
MQDistributionList 101
MQDistributionListItem 103
MQEnvironment 62, 67, 104
MQException 110
MQGetMessageOptions 112
MQGetMessageOptions fields
platform dependency 92
MQGMO_* values
variations by environment 90
MQIVP
listing 15
sample application 14
tracing 15
mqjavac
using to verify 27
MQManagedObject 116
Index
447
448
N
NAME_PREFIX property 41
NAME_READABILITY_MARKER
property 41
names, of Topics 210
naming considerations, LDAP 45
non-durable subscribers 214
O
object creation, error conditions 54
ObjectMessage
interface 327
type 196
objects
administered 190
JMS, administering 43
JMS, creating 45
JMS, properties 46
message 225
retrieving from JNDI 190
objects and properties, valid
combinations 51
obtaining a session 193
one-phase optimization, with WebSphere
Application Server 414
operations on queue managers 67
options
connection 4
subscribers 213
overview 3
P
package
com.ibm.jms 265
com.mq.ibm.jms 264
javax.jms 261
PERSISTENCE object property 48, 401
platform differences 423
point-to-point installation verification 28
poison messages 246
POLLINGINT object property 48
PORT object property 48, 401
postcard.ini 22
prerequisite software 6
PRIORITY object property 48, 401
problems, solving 15, 36
problems, solving in publish/subscribe
mode 219
processes, accessing 68
programmers, introduction 57
programming
bindings connection 62
client connections 61
compiling 86
connections 61
multithreaded 72
tracing 86
writing 61
programming interface 58
programs
JMS, writing 189
publish/subscribe, writing 204
running 35, 86
tracing 36
properties
client 51
dependencies 51
for Secure Sockets Layer 53
for WebSphere MQ Event Broker 52
mapping between admin. tool and
programs 399
message 225
of exit strings 52
of JMS objects 46
queue, setting 193
properties and objects, valid
combinations 51
PROVIDER_PASSWORD property 41
PROVIDER_URL property 40
PROVIDER_USERDN property 41
providerutil.jar 7
PSIVT (Installation Verification Test
program) 32
PSIVTRun utility 32, 401
PSReportDump application 223
PUBACKINT object property 48
publications (publish/subscribe), local
suppressing 214
publish/subscribe
installation verification test program
(PSIVT) 32
sample application with WebSphere
Application Server 416
setup for 24
publish/subscribe broker, connecting
to 409
publishing messages 209
Q
QMANAGER object property 48, 401
Queue
interface 328
object 190
queue manager
configuring for clients 13
connecting to 68
disconnecting from 68
operations on 67
QUEUE object property 48, 401
queue properties
setting 193
setting with set methods 195
QueueBrowser interface 330
QueueConnection interface 332
R
reading strings 70
receiving
messages 196
messages in publish/subscribe
mode 209
RECEXIT object property 48, 401
RECEXITINIT object property 48, 401
report options, message 126, 247
reports, broker 223
resources, closing 197
restrictions and variations
to core classes 423
retrieving objects from JNDI 190
runjms utility 35, 401
running
applets 86
applications under CICS Transaction
Server 423
in a Web browser 5
programs 35
standalone program 5
the IVT 28
the PSIVT 32
WebSphere MQ classes for Java
programs 86
with appletviewer 5
your own programs 15
runtime
creating factories 191
creating Topics 212
errors, handling 198
S
sample applet
using to verify 27
sample application
bean-managed transactions 416
bindings mode 65
container-managed transactions 415
publish/subscribe 205
publish/subscribe with WebSphere
Application Server 416
tracing 15
using Application Server
Facilities 253
using to verify 14
WebSphere MQ JMS with WebSphere
Application Server 414
sample classpath settings 8
sample code
applet 62
ServerSession 249
ServerSessionPool 249
Sample1EJB.java 415
Sample2EJB.java 416
Sample3EJB.java 416
schema definition, LDAP 403
sslSocketFactory property 85
standalone program, running 5
starting a connection 192
starting the administration tool 39
STATREFRESHINT object property 48
stream message 225
StreamMessage
interface 350
type 196
strings, reading and writing 70
subcontexts, manipulating 43
subscriber options 213
subscriptions, receiving 209
subset of messages, selecting 197, 225
SUBSTORE object property 48
Sun JMS interfaces and classes 261
Sun Web site 3
SupportPac MA1G
special considerations for 421
suppressing local publications 214
switch file for JTA/JDBC 79
SYNCPOINTALLGETS object
property 48
T
TARGCLIENT object property 48, 401
TCP/IP
client verifying 14
connection, programming 61
TEMPMODEL object property 48, 401
TemporaryQueue interface 358
TemporaryTopic interface 359
termination, unexpected 220
testing WebSphere MQ classes for Java
programs 86
text message 225
TextMessage
interface 360
type 196
tokens, connection pooling 73
Topic
interface 207, 361
names 210
names, wildcards 211
object 190
TOPIC object property 48, 401
TopicConnection 207
interface 364
TopicConnectionFactory 207
interface 367
TopicLoad.java 257
TopicPublisher 209
interface 373
TopicRequestor class 376
TopicSession 207
interface 378
TopicSubscriber 209
interface 382
trace, default output location 35
tracing
programs 86
the sample application 15
WebSphere MQ for Java Message
Service 36
transactions
bean-managed 414
Index
449
transactions (continued)
container-managed 414
sample application 415, 416
TRANSPORT object property 48, 401
transport, choosing 192
two-phase commit, with WebSphere
Application Server 414
types of JMS message 195, 225
U
unexpected application termination 220
uniform resource identifier (URI) for
queue properties 194
URI for queue properties 194
USE_INITIAL_DIR_CONTEXT
property 41
USECONPOOLING object property 48
user exits
with SSL 72
writing 72
user exits, writing 198
uses for WebSphere MQ 3
using
WebSphere MQ base Java 13
utilities provided with WebSphere MQ
classes for Java Message Service 401
V
valid combinations of objects and
properties 51
verbs, WebSphere MQ supported 58
verification
with JNDI (point-to-point) 30
with JNDI (publish/subscribe) 34
without JNDI (point-to-point) 29
without JNDI (publish/subscribe) 32
verifying
client mode installation 27
TCP/IP clients 14
with the sample applet 27
with the sample application 14
your installation 17
versions of software required 6
VisiBroker
using 4
W
Web browser
using 5
Web server, configuring 10
WebSphere Application Server 249, 413
configuration 42
CosNaming namespace 40
CosNaming repository 40, 42
using with JMS 413
WebSphere MQ
connection, losing 220
exceptions 198
interfaces 189
messages 229
WebSphere MQ classes for Java
classes 95
450
X
XAConnection interface 383
XAConnectionFactory interface 384
XAQueueConnection interface 332, 385
XAQueueConnectionFactory
interface 334, 386
XAQueueSession interface 388
XAResource 389
XASession interface 389
XATopicConnection interface 391
XATopicConnectionFactory interface 393
XATopicSession interface 395
Z
z/OS & OS/390
differences with 91
451
452
Printed in U.S.A.
SC34-6066-00
Spine information:
WebSphere MQ