Skip to content

Commit 67256c6

Browse files
authored
[AMQ-7309] Update to jakarta.jms/jakarta.jms-api:2.0.3 (#682)
- API update only - Throw UnsupportedOperationException - Disable activemq-camel from build - Formatting fixes - Use geronimo-jms for osgi-related artifacts - Fix features.xml invalid xml header - Add a unit test to confirm JMS 2.0 methods for phase 1 (throw UnsupportedOperationException) - Add deliveryTime field to Message - Minor formatting fixes
1 parent 07c2704 commit 67256c6

File tree

48 files changed

+1046
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1046
-59
lines changed

activemq-all/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
<include>org.apache.activemq.protobuf:activemq-protobuf</include>
105105
<include>org.fusesource.hawtbuf:hawtbuf</include>
106106
<include>org.jasypt:jasypt</include>
107-
<include>org.apache.geronimo.specs:geronimo-jms_1.1_spec</include>
107+
<include>jakarta.jms:jakarta.jms-api</include>
108108
<include>org.apache.geronimo.specs:geronimo-jta_1.1_spec</include>
109109
<include>org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec</include>
110110
<include>org.apache.geronimo.specs:geronimo-annotation_1.0_spec</include>
@@ -319,9 +319,9 @@
319319
<optional>true</optional>
320320
</dependency>
321321
<dependency>
322-
<groupId>org.apache.geronimo.specs</groupId>
323-
<artifactId>geronimo-jms_1.1_spec</artifactId>
324-
<version>1.1.1</version>
322+
<groupId>jakarta.jms</groupId>
323+
<artifactId>jakarta.jms-api</artifactId>
324+
<version>2.0.3</version>
325325
<classifier>sources</classifier>
326326
<optional>true</optional>
327327
</dependency>
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.activemq;
19+
20+
import javax.jms.Connection;
21+
import javax.jms.JMSException;
22+
import javax.jms.MessageProducer;
23+
import javax.jms.Session;
24+
25+
import org.junit.After;
26+
import org.junit.AfterClass;
27+
import org.junit.Before;
28+
import org.junit.BeforeClass;
29+
import org.junit.Test;
30+
31+
public class ActiveMQJms2Test {
32+
33+
protected static ActiveMQConnectionFactory activemqConnectionFactory = null;
34+
35+
protected Connection connection = null;
36+
protected Session session = null;
37+
protected MessageProducer messageProducer = null;
38+
39+
@BeforeClass
40+
public static void setUpClass() {
41+
activemqConnectionFactory = new ActiveMQConnectionFactory("vm://localhost?marshal=false&broker.persistent=false");
42+
}
43+
44+
@AfterClass
45+
public static void tearDownClass() {
46+
activemqConnectionFactory = null;
47+
}
48+
49+
@Before
50+
public void setUp() throws JMSException {
51+
connection = activemqConnectionFactory.createConnection();
52+
connection.start();
53+
54+
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
55+
56+
messageProducer = session.createProducer(session.createQueue("AMQ.JMS2.TEST"));
57+
}
58+
59+
@After
60+
public void tearDown() {
61+
if(messageProducer != null) {
62+
try { messageProducer.close(); } catch (Exception e) { } finally { messageProducer = null; }
63+
}
64+
65+
if(session != null) {
66+
try { session.close(); } catch (Exception e) { } finally { session = null; }
67+
}
68+
69+
if(connection != null) {
70+
try { connection.close(); } catch (Exception e) { } finally { connection = null; }
71+
}
72+
}
73+
74+
@Test(expected = UnsupportedOperationException.class)
75+
public void testConnectionFactoryCreateContext() {
76+
activemqConnectionFactory.createContext();
77+
}
78+
79+
@Test(expected = UnsupportedOperationException.class)
80+
public void testConnectionFactoryCreateContextSession() {
81+
activemqConnectionFactory.createContext(Session.AUTO_ACKNOWLEDGE);
82+
}
83+
84+
@Test(expected = UnsupportedOperationException.class)
85+
public void testConnectionFactoryCreateContextUserPass() {
86+
activemqConnectionFactory.createContext("admin", "admin");
87+
}
88+
89+
@Test(expected = UnsupportedOperationException.class)
90+
public void testConnectionFactoryCreateContextUserPassSession() {
91+
activemqConnectionFactory.createContext("admin", "admin", Session.AUTO_ACKNOWLEDGE);
92+
}
93+
94+
@Test(expected = UnsupportedOperationException.class)
95+
public void testConnectionSharedConnectionConsumer() throws JMSException {
96+
connection.createSharedConnectionConsumer(null, null, null, null, 10);
97+
}
98+
99+
@Test(expected = UnsupportedOperationException.class)
100+
public void testConnectionSharedDurableConnectionConsumer() throws JMSException {
101+
connection.createSharedDurableConnectionConsumer(null, null, null, null, 10);
102+
}
103+
104+
@Test(expected = UnsupportedOperationException.class)
105+
public void testSessionAckMode() throws JMSException {
106+
connection.createSession(Session.AUTO_ACKNOWLEDGE);
107+
}
108+
109+
@Test(expected = UnsupportedOperationException.class)
110+
public void testSessionDurableConsumer() throws JMSException {
111+
session.createDurableConsumer(null, null);
112+
}
113+
114+
@Test(expected = UnsupportedOperationException.class)
115+
public void testSessionDurableConsumerSelectorNoLocal() throws JMSException {
116+
session.createDurableConsumer(null, null, null, true);
117+
}
118+
119+
@Test(expected = UnsupportedOperationException.class)
120+
public void testSessionSharedConsumer() throws JMSException {
121+
session.createSharedConsumer(null, null);
122+
}
123+
124+
@Test(expected = UnsupportedOperationException.class)
125+
public void testSessionSharedConsumerSelector() throws JMSException {
126+
session.createSharedConsumer(null, null, null);
127+
}
128+
129+
@Test(expected = UnsupportedOperationException.class)
130+
public void testSessionSharedDurableConsumer() throws JMSException {
131+
session.createSharedDurableConsumer(null, null);
132+
}
133+
134+
@Test(expected = UnsupportedOperationException.class)
135+
public void testSessionSharedDurableConsumerSelector() throws JMSException {
136+
session.createSharedDurableConsumer(null, null, null);
137+
}
138+
139+
@Test(expected = UnsupportedOperationException.class)
140+
public void testProducerDeliveryDelayGet() throws JMSException {
141+
messageProducer.getDeliveryDelay();
142+
}
143+
144+
@Test(expected = UnsupportedOperationException.class)
145+
public void testProducerDeliveryDelaySet() throws JMSException {
146+
messageProducer.setDeliveryDelay(1000l);
147+
}
148+
149+
@Test(expected = UnsupportedOperationException.class)
150+
public void testProducerSendMessageCompletionListener() throws JMSException {
151+
messageProducer.send(session.createQueue("AMQ.TEST"), null);
152+
}
153+
154+
@Test(expected = UnsupportedOperationException.class)
155+
public void testProducerSendMessageQoSParamsCompletionListener() throws JMSException {
156+
messageProducer.send(null, 1, 4, 0l, null);
157+
}
158+
159+
@Test(expected = UnsupportedOperationException.class)
160+
public void testProducerSendDestinationMessageCompletionListener() throws JMSException {
161+
messageProducer.send(session.createQueue("AMQ.TEST"), null, null);
162+
}
163+
164+
@Test(expected = UnsupportedOperationException.class)
165+
public void testProducerSendDestinationMessageQosParamsCompletionListener() throws JMSException {
166+
messageProducer.send(session.createQueue("AMQ.TEST"), null, 1, 4, 0l, null);
167+
}
168+
169+
}

activemq-client/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
<artifactId>slf4j-api</artifactId>
4444
</dependency>
4545
<dependency>
46-
<groupId>org.apache.geronimo.specs</groupId>
47-
<artifactId>geronimo-jms_1.1_spec</artifactId>
46+
<groupId>jakarta.jms</groupId>
47+
<artifactId>jakarta.jms-api</artifactId>
4848
</dependency>
4949
<dependency>
5050
<groupId>org.fusesource.hawtbuf</groupId>
@@ -58,12 +58,13 @@
5858
<artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
5959
</dependency>
6060

61-
<!-- for ftp blob upload/download -->
61+
<!-- for ftp blob upload/download -->
6262
<dependency>
6363
<groupId>commons-net</groupId>
6464
<artifactId>commons-net</artifactId>
6565
<optional>true</optional>
6666
</dependency>
67+
6768
<!-- for zerconf discovery -->
6869
<dependency>
6970
<groupId>javax.jmdns</groupId>

activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,44 @@ public JMSConnectionStatsImpl getConnectionStats() {
304304
return stats;
305305
}
306306

307+
/**
308+
* Creates a <CODE>Session</CODE> object.
309+
*
310+
* @throws JMSException if the <CODE>Connection</CODE> object fails to
311+
* create a session due to some internal error or lack of
312+
* support for the specific transaction and acknowledgement
313+
* mode.
314+
* @since 2.0
315+
*/
316+
@Override
317+
public Session createSession() throws JMSException {
318+
throw new UnsupportedOperationException("createSession() is unsupported");
319+
}
320+
321+
/**
322+
* Creates a <CODE>Session</CODE> object.
323+
*
324+
* @param acknowledgeMode indicates whether the consumer or the client will
325+
* acknowledge any messages it receives; ignored if the
326+
* session is transacted. Legal values are
327+
* <code>Session.AUTO_ACKNOWLEDGE</code>,
328+
* <code>Session.CLIENT_ACKNOWLEDGE</code>, and
329+
* <code>Session.DUPS_OK_ACKNOWLEDGE</code>.
330+
* @return a newly created session
331+
* @throws JMSException if the <CODE>Connection</CODE> object fails to
332+
* create a session due to some internal error or lack of
333+
* support for the specific transaction and acknowledgement
334+
* mode.
335+
* @see Session#AUTO_ACKNOWLEDGE
336+
* @see Session#CLIENT_ACKNOWLEDGE
337+
* @see Session#DUPS_OK_ACKNOWLEDGE
338+
* @since 2.0
339+
*/
340+
@Override
341+
public Session createSession(int sessionMode) throws JMSException {
342+
throw new UnsupportedOperationException("createSession(int sessionMode) is unsupported");
343+
}
344+
307345
/**
308346
* Creates a <CODE>Session</CODE> object.
309347
*
@@ -826,10 +864,32 @@ public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String su
826864
return new ActiveMQConnectionConsumer(this, sessionPool, info);
827865
}
828866

829-
// Properties
830-
// -------------------------------------------------------------------------
867+
/**
868+
*
869+
* @see javax.jms.ConnectionConsumer
870+
* @since 2.0
871+
*/
872+
@Override
873+
public ConnectionConsumer createSharedConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool,
874+
int maxMessages) throws JMSException {
875+
throw new UnsupportedOperationException("createSharedConnectionConsumer() is not supported");
876+
}
831877

832878
/**
879+
*
880+
* @see javax.jms.ConnectionConsumer
881+
* @since 2.0
882+
*/
883+
@Override
884+
public ConnectionConsumer createSharedDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool,
885+
int maxMessages) throws JMSException {
886+
throw new UnsupportedOperationException("createSharedConnectionConsumer() is not supported");
887+
}
888+
889+
// Properties
890+
// -------------------------------------------------------------------------
891+
892+
/**
833893
* Returns true if this connection has been started
834894
*
835895
* @return true if this Connection is started

activemq-client/src/main/java/org/apache/activemq/ActiveMQConnectionFactory.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import javax.jms.Connection;
2828
import javax.jms.ConnectionFactory;
2929
import javax.jms.ExceptionListener;
30+
import javax.jms.JMSContext;
3031
import javax.jms.JMSException;
3132
import javax.jms.QueueConnection;
3233
import javax.jms.QueueConnectionFactory;
@@ -285,6 +286,38 @@ public TopicConnection createTopicConnection() throws JMSException {
285286
public TopicConnection createTopicConnection(String userName, String password) throws JMSException {
286287
return createActiveMQConnection(userName, password);
287288
}
289+
290+
/**
291+
* @return Returns the JMSContext.
292+
*/
293+
@Override
294+
public JMSContext createContext() {
295+
throw new UnsupportedOperationException("createContext() is not supported");
296+
}
297+
298+
/**
299+
* @return Returns the JMSContext.
300+
*/
301+
@Override
302+
public JMSContext createContext(String userName, String password) {
303+
throw new UnsupportedOperationException("createContext() is not supported");
304+
}
305+
306+
/**
307+
* @return Returns the JMSContext.
308+
*/
309+
@Override
310+
public JMSContext createContext(String userName, String password, int sessionMode) {
311+
throw new UnsupportedOperationException("createContext() is not supported");
312+
}
313+
314+
/**
315+
* @return Returns the JMSContext.
316+
*/
317+
@Override
318+
public JMSContext createContext(int sessionMode) {
319+
throw new UnsupportedOperationException("createContext() is not supported");
320+
}
288321

289322
/**
290323
* @return the StatsImpl associated with this ConnectionFactory.

activemq-client/src/main/java/org/apache/activemq/ActiveMQMessageProducer.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121
import java.util.concurrent.atomic.AtomicLong;
2222

23+
import javax.jms.CompletionListener;
2324
import javax.jms.Destination;
2425
import javax.jms.IllegalStateException;
2526
import javax.jms.InvalidDestinationException;
@@ -220,7 +221,43 @@ protected void checkClosed() throws IllegalStateException {
220221
*/
221222
@Override
222223
public void send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException {
223-
this.send(destination, message, deliveryMode, priority, timeToLive, null);
224+
this.send(destination, message, deliveryMode, priority, timeToLive, (AsyncCallback)null);
225+
}
226+
227+
/**
228+
*
229+
* @param message the message to send
230+
* @param CompletionListener to callback
231+
* @throws JMSException if the JMS provider fails to send the message due to
232+
* some internal error.
233+
* @throws UnsupportedOperationException if an invalid destination is
234+
* specified.
235+
* @throws InvalidDestinationException if a client uses this method with an
236+
* invalid destination.
237+
* @see javax.jms.Session#createProducer
238+
* @since 2.0
239+
*/
240+
@Override
241+
public void send(Message message, CompletionListener completionListener) throws JMSException {
242+
throw new UnsupportedOperationException("send(Message, CompletionListener) is not supported");
243+
244+
}
245+
246+
@Override
247+
public void send(Message message, int deliveryMode, int priority, long timeToLive,
248+
CompletionListener completionListener) throws JMSException {
249+
throw new UnsupportedOperationException("send(Message, deliveryMode, priority, timetoLive, CompletionListener) is not supported");
250+
}
251+
252+
@Override
253+
public void send(Destination destination, Message message, CompletionListener completionListener) throws JMSException {
254+
throw new UnsupportedOperationException("send(Destination, Message, CompletionListener) is not supported");
255+
}
256+
257+
@Override
258+
public void send(Destination destination, Message message, int deliveryMode, int priority, long timeToLive,
259+
CompletionListener completionListener) throws JMSException {
260+
throw new UnsupportedOperationException("send(Destination, Message, deliveryMode, priority, timetoLive, CompletionListener) is not supported");
224261
}
225262

226263
public void send(Message message, AsyncCallback onComplete) throws JMSException {

0 commit comments

Comments
 (0)