blob: 39ed67ea3b5884476d62d5a58279ee904276e619 [file] [log] [blame]
Vinay Vishal7c4c4fc2019-01-28 12:01:04 +05301type=page
2status=published
3title=create-jms-resource
4next=create-jndi-resource.html
5prev=create-jms-host.html
6~~~~~~
7create-jms-resource
8===================
9
10[[create-jms-resource-1]][[GSRFM00040]][[create-jms-resource]]
11
12create-jms-resource
13-------------------
14
15creates a JMS resource
16
17[[sthref352]]
18
19Synopsis
20
21[source,oac_no_warn]
22----
23asadmin [asadmin-options] create-jms-resource [--help]
24--restype type
25[--target target]
26[--enabled={true|false}]
27[--description text]
28[--property (name=value)[:name=value]*]
29[--force={false|true}]
30jndi_name
31----
32
33[[sthref353]]
34
35Description
36
37The `create-jms-resource` subcommand creates a Java Message Service
38(JMS) connection factory resource or a JMS destination resource.
39
40This subcommand is supported in remote mode only. Remote `asadmin`
41subcommands require a running domain administration server (DAS).
42
43[[sthref354]]
44
45Options
46
47asadmin-options::
48 Options for the `asadmin` utility. For information about these
49 options, see the link:asadmin.html#asadmin-1m[`asadmin`(1M)] help page.
50`--help`::
51`-?`::
52 Displays the help text for the subcommand.
53`--restype`::
Gaurav Gupta36555072020-03-26 14:10:23 +053054 The JMS resource type, which can be `jakarta.jms.Topic`,
55 `jakarta.jms.Queue`, `jakarta.jms.ConnectionFactory`,
56 `jakarta.jms.TopicConnectionFactory`, or
57 `jakarta.jms.QueueConnectionFactory`.
Vinay Vishal7c4c4fc2019-01-28 12:01:04 +053058`--target`::
59 Creates the JMS resource only for the specified target. Valid values
60 are as follows: +
61
62[width="100%",cols="100%",]
63|=======================================================================
64a|
65Note:
66
67The resource is always created for the domain as a whole, but the
68`<resource-ref>` element for the resource is only created for the
69specified `--target`. This means that although the resource is defined
70at the domain level, it is only active at the specified `--target`.
71
72|=======================================================================
73
74 `server`;;
75 Creates the JMS resource for the default server instance. This is
76 the default value.
77 `domain`;;
78 Creates the JMS resource for the domain.
79 cluster-name;;
80 Creates the JMS resource for every server instance in the specified
81 cluster.
82 instance-name;;
83 Creates the JMS resource for the specified server instance.
84`--enabled`::
85 If set to true (the default), the resource is enabled at runtime.
86`--description`::
87 Text providing details about the JMS resource.
88`--property`::
89 Optional attribute name/value pairs for configuring the JMS resource. +
90 You can specify the following properties for a connection factory
91 resource: +
92 `ClientId`;;
93 A client ID for a connection factory that will be used by a durable
94 subscriber.
95 `AddressList`;;
96 A comma-separated list of message queue addresses that specify the
97 host names (and, optionally, port numbers) of a message broker
98 instance or instances with which your application will communicate.
99 For example, the value could be `earth` or `earth:7677`. Specify the
100 port number if the message broker is running on a port other than
101 the default (7676). The default value is an address list composed
102 from the JMS hosts defined in the server's JMS service
103 configuration. The default value is `localhost` and the default port
104 number is 7676. The client will attempt a connection to a broker on
105 port 7676 of the local host.
106 `UserName`;;
107 The user name for the connection factory. The default value is
108 `guest`.
109 `Password`;;
110 The password for the connection factory. The default value is
111 `guest`.
112 `ReconnectEnabled`;;
113 A value of `true` indicates that the client runtime attempts to
114 reconnect to a message server (or the list of addresses in the
115 `AddressList`) when a connection is lost. The default value is
116 `false`.
117 `ReconnectAttempts`;;
118 The number of attempts to connect (or reconnect) for each address in
119 the `AddressList` before the client runtime tries the next address
120 in the list. A value of -1 indicates that the number of reconnect
121 attempts is unlimited (the client runtime attempts to connect to the
122 first address until it succeeds). The default value is 6.
123 `ReconnectInterval`;;
124 The interval in milliseconds between reconnect attempts. This
125 applies to attempts on each address in the `AddressList` and for
126 successive addresses in the list. If the interval is too short, the
127 broker does not have time to recover. If it is too long, the
128 reconnect might represent an unacceptable delay. The default value
129 is 30,000 milliseconds.
130 `AddressListBehavior`;;
131 Specifies whether connection attempts are in the order of addresses
132 in the `AddressList` (`PRIORITY`) or in a random order (`RANDOM`).
133 `PRIORITY` means that the reconnect will always try to connect to
134 the first server address in the `AddressList` and will use another
135 one only if the first broker is not available. If you have many
136 clients attempting a connection using the same connection factory,
137 specify `RANDOM` to prevent them from all being connected to the
138 same address. The default value is the `AddressListBehavior` value
139 of the server's JMS service configuration.
140 `AddressListIterations`;;
141 The number of times the client runtime iterates through the
142 `AddressList` in an effort to establish (or re-establish) a
143 connection). A value of -1 indicates that the number of attempts is
144 unlimited. The default value is -1. +
145 Additionally, you can specify `connector-connection-pool` attributes
146 as connector resource properties. For a list of these attributes, see
147 "link:../application-deployment-guide/dd-elements.html#GSDPG00124[connector-connection-pool]" in GlassFish Server Open
148 Source Edition Application Deployment Guide. +
149 You can specify the following properties for a destination resource: +
150 `Name`;;
151 The name of the physical destination to which the resource will
152 refer. The physical destination is created automatically when you
153 run an application that uses the destination resource. You can also
154 create a physical destination with the `create-jmsdest` subcommand.
155 If you do not specify this property, the JMS service creates a
156 physical destination with the same name as the destination resource
157 (replacing any forward slash in the JNDI name with an underscore).
158 `Description`;;
159 A description of the physical destination.
160`--force`::
161 Specifies whether the subcommand overwrites the existing JMS resource
162 of the same name. The default value is `false`.
163
164[[sthref355]]
165
166Operands
167
168jndi_name::
169 The JNDI name of the JMS resource to be created.
170
171[[sthref356]]
172
173Examples
174
175[[GSRFM497]][[sthref357]]
176
177Example 1   Creating a JMS connection factory resource for durable
178subscriptions
179
180The following subcommand creates a connection factory resource of type
Gaurav Gupta36555072020-03-26 14:10:23 +0530181`jakarta.jms.ConnectionFactory` whose JNDI name is
Vinay Vishal7c4c4fc2019-01-28 12:01:04 +0530182`jms/DurableConnectionFactory`. The `ClientId` property sets a client ID
183on the connection factory so that it can be used for durable
184subscriptions. The JNDI name for a JMS resource customarily includes the
185`jms/` naming subcontext.
186
187[source,oac_no_warn]
188----
Gaurav Gupta36555072020-03-26 14:10:23 +0530189asadmin> create-jms-resource --restype jakarta.jms.ConnectionFactory
Vinay Vishal7c4c4fc2019-01-28 12:01:04 +0530190--description "connection factory for durable subscriptions"
191--property ClientId=MyID jms/DurableConnectionFactory
192Connector resource jms/DurableConnectionFactory created.
193Command create-jms-resource executed successfully.
194----
195
196[[GSRFM498]][[sthref358]]
197
198Example 2   Creating a JMS destination resource
199
200The following subcommand creates a destination resource whose JNDI name
201is `jms/MyQueue`. The `Name` property specifies the physical destination
202to which the resource refers.
203
204[source,oac_no_warn]
205----
Gaurav Gupta36555072020-03-26 14:10:23 +0530206asadmin> create-jms-resource --restype jakarta.jms.Queue
Vinay Vishal7c4c4fc2019-01-28 12:01:04 +0530207--property Name=PhysicalQueue jms/MyQueue
208Administered object jms/MyQueue created.
209Command create-jms-resource executed successfully.
210----
211
212[[sthref359]]
213
214Exit Status
215
2160::
217 subcommand executed successfully
2181::
219 error in executing the subcommand
220
221[[sthref360]]
222
223See Also
224
225link:asadmin.html#asadmin-1m[`asadmin`(1M)]
226
227link:delete-jms-resource.html#delete-jms-resource-1[`delete-jms-resource`(1)],
228link:list-jms-resources.html#list-jms-resources-1[`list-jms-resources`(1)]
229
230