Skip to content

Commit 7b9c30f

Browse files
committed
Explicit documentation notes on JMS 2.0 vs 1.1 compatibility
Issue: SPR-17583
1 parent 474ac2d commit 7b9c30f

File tree

6 files changed

+57
-25
lines changed

6 files changed

+57
-25
lines changed

spring-jms/src/main/java/org/springframework/jms/connection/CachingConnectionFactory.java

+5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
* lead to queue/topic mode, respectively; generic {@code createConnection}
6464
* calls will lead to a JMS 1.1 connection which is able to serve both modes.
6565
*
66+
* <p>As of Spring Framework 5, this class supports JMS 2.0 {@code JMSContext}
67+
* calls and therefore requires the JMS 2.0 API to be present at runtime.
68+
* It may nevertheless run against a JMS 1.1 driver (bound to the JMS 2.0 API)
69+
* as long as no actual JMS 2.0 calls are triggered by the application's setup.
70+
*
6671
* <p><b>NOTE: This ConnectionFactory requires explicit closing of all Sessions
6772
* obtained from its shared Connection.</b> This is the usual recommendation for
6873
* native JMS access code anyway. However, with this ConnectionFactory, its use

spring-jms/src/main/java/org/springframework/jms/connection/DelegatingConnectionFactory.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,6 +36,11 @@
3636
* if necessary (e.g. when running JMS 1.0.2 API based code against a generic
3737
* JMS 1.1 ConnectionFactory, such as ActiveMQ's PooledConnectionFactory).
3838
*
39+
* <p>As of Spring Framework 5, this class supports JMS 2.0 {@code JMSContext}
40+
* calls and therefore requires the JMS 2.0 API to be present at runtime.
41+
* It may nevertheless run against a JMS 1.1 driver (bound to the JMS 2.0 API)
42+
* as long as no actual JMS 2.0 calls are triggered by the application's setup.
43+
*
3944
* <p>This class allows for being subclassed, with subclasses overriding only
4045
* those methods (such as {@link #createConnection()}) that should not simply
4146
* delegate to the target ConnectionFactory.

spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
* lead to queue/topic mode, respectively; generic {@code createConnection}
6262
* calls will lead to a JMS 1.1 connection which is able to serve both modes.
6363
*
64+
* <p>As of Spring Framework 5, this class supports JMS 2.0 {@code JMSContext}
65+
* calls and therefore requires the JMS 2.0 API to be present at runtime.
66+
* It may nevertheless run against a JMS 1.1 driver (bound to the JMS 2.0 API)
67+
* as long as no actual JMS 2.0 calls are triggered by the application's setup.
68+
*
6469
* <p>Useful for testing and standalone environments in order to keep using the
6570
* same Connection for multiple {@link org.springframework.jms.core.JmsTemplate}
6671
* calls, without having a pooling ConnectionFactory underneath. This may span

spring-jms/src/main/java/org/springframework/jms/connection/TransactionAwareConnectionFactoryProxy.java

+5
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@
7272
* (e.g. to perform manual transaction control). For typical application purposes,
7373
* simply use the standard JMS Session interface.
7474
*
75+
* <p>As of Spring Framework 5, this class delegates JMS 2.0 {@code JMSContext}
76+
* calls and therefore requires the JMS 2.0 API to be present at runtime.
77+
* It may nevertheless run against a JMS 1.1 driver (bound to the JMS 2.0 API)
78+
* as long as no actual JMS 2.0 calls are triggered by the application's setup.
79+
*
7580
* @author Juergen Hoeller
7681
* @since 2.0
7782
* @see UserCredentialsConnectionFactoryAdapter

spring-jms/src/main/java/org/springframework/jms/connection/UserCredentialsConnectionFactoryAdapter.java

+5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
* definition just for the <i>option</i> of implicitly passing in user credentials
6464
* if the particular target ConnectionFactory requires it.
6565
*
66+
* <p>As of Spring Framework 5, this class delegates JMS 2.0 {@code JMSContext}
67+
* calls and therefore requires the JMS 2.0 API to be present at runtime.
68+
* It may nevertheless run against a JMS 1.1 driver (bound to the JMS 2.0 API)
69+
* as long as no actual JMS 2.0 calls are triggered by the application's setup.
70+
*
6671
* @author Juergen Hoeller
6772
* @since 1.2
6873
* @see #createConnection

src/docs/asciidoc/integration.adoc

+31-24
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ usual (Spring) POJOs. Currently, Spring supports the following remoting technolo
2424

2525
* *Remote Method Invocation (RMI)*: Through the use of `RmiProxyFactoryBean` and
2626
`RmiServiceExporter`, Spring supports both traditional RMI (with `java.rmi.Remote`
27-
interfaces and `java.rmi.RemoteException`) and transparent remoting through RMI invokers
28-
(with any Java interface).
27+
interfaces and `java.rmi.RemoteException`) and transparent remoting through RMI
28+
invokers (with any Java interface).
2929
* *Spring's HTTP invoker*: Spring provides a special remoting strategy that allows
3030
for Java serialization though HTTP, supporting any Java interface (as the RMI
31-
invoker does). The corresponding support classes are `HttpInvokerProxyFactoryBean` and
32-
`HttpInvokerServiceExporter`.
31+
invoker does). The corresponding support classes are `HttpInvokerProxyFactoryBean`
32+
and `HttpInvokerServiceExporter`.
3333
* *Hessian*: By using Spring's `HessianProxyFactoryBean` and the
3434
`HessianServiceExporter`, you can transparently expose your services through the
3535
lightweight binary HTTP-based protocol provided by Caucho.
36-
* *JAX-WS*: Spring provides remoting support for web services through JAX-WS (the
37-
successor of JAX-RPC, as introduced in Java EE 5 and Java 6).
36+
* *JAX-WS*: Spring provides remoting support for web services through JAX-WS.
3837
* *JMS*: Remoting by using JMS as the underlying protocol is supported through the
3938
`JmsInvokerServiceExporter` and `JmsInvokerProxyFactoryBean` classes.
4039
* *AMQP*: Remoting by using AMQP as the underlying protocol is supported by the Spring
@@ -627,7 +626,6 @@ and Spring's `@Autowired` configuration annotation is still honored):
627626
public List<Account> getAccounts(String name) {
628627
return biz.getAccounts(name);
629628
}
630-
631629
}
632630
----
633631
====
@@ -732,8 +730,8 @@ accordingly first. Check the JAX-WS documentation for details on those requireme
732730
[[remoting-jms]]
733731
=== Exposing Services through JMS
734732

735-
You can also expose services transparently by using JMS as the underlying
736-
communication protocol. The JMS remoting support in the Spring Framework is pretty basic.
733+
You can also expose services transparently by using JMS as the underlying communication
734+
protocol. The JMS remoting support in the Spring Framework is pretty basic.
737735
It sends and receives on the `same thread` and in the same non-transactional
738736
`Session`. As a result, throughput is implementation-dependent. Note that these
739737
single-threaded and non-transactional constraints apply only to Spring's JMS
@@ -751,7 +749,6 @@ The following interface is used on both the server and the client sides:
751749
public interface CheckingAccountService {
752750
753751
public void cancelAccount(Long accountId);
754-
755752
}
756753
----
757754
====
@@ -769,13 +766,12 @@ The following simple implementation of the preceding interface is used on the se
769766
public void cancelAccount(Long accountId) {
770767
System.out.println("Cancelling account [" + accountId + "]");
771768
}
772-
773769
}
774770
----
775771
====
776772

777-
The following configuration file contains the JMS-infrastructure beans that are shared on both
778-
the client and server:
773+
The following configuration file contains the JMS-infrastructure beans that are shared
774+
on both the client and the server:
779775

780776
====
781777
[source,xml,indent=0]
@@ -846,7 +842,6 @@ On the server, you need to expose the service object that uses the
846842
public static void main(String[] args) throws Exception {
847843
new ClassPathXmlApplicationContext(new String[]{"com/foo/server.xml", "com/foo/jms.xml"});
848844
}
849-
850845
}
851846
----
852847
====
@@ -897,7 +892,6 @@ proxy takes care of forwarding the call to the server-side object via JMS):
897892
CheckingAccountService service = (CheckingAccountService) ctx.getBean("checkingAccountService");
898893
service.cancelAccount(new Long(10));
899894
}
900-
901895
}
902896
----
903897
====
@@ -916,8 +910,8 @@ Auto-detection is not implemented for remote interfaces
916910
917911
The main reason why auto-detection of implemented interfaces does not occur for remote
918912
interfaces is to avoid opening too many doors to remote callers. The target object might
919-
implement internal callback interfaces, such as `InitializingBean` or `DisposableBean`, which
920-
one would not want to expose to callers.
913+
implement internal callback interfaces, such as `InitializingBean` or `DisposableBean`
914+
which one would not want to expose to callers.
921915
922916
Offering a proxy with all interfaces implemented by the target usually does not matter
923917
in the local case. However, when you export a remote service, you should expose a specific
@@ -936,13 +930,13 @@ effort and puts you on the safe side regarding controlled exposure of specific m
936930
[[remoting-considerations]]
937931
=== Considerations when Choosing a Technology
938932

939-
Each and every technology presented here has its drawbacks. When choosing a technology, you should carefully
940-
consider your needs, the services you expose, and the objects you send
941-
over the wire.
933+
Each and every technology presented here has its drawbacks. When choosing a technology,
934+
you should carefully consider your needs, the services you expose, and the objects you
935+
send over the wire.
942936

943937
When using RMI, you cannot access the objects through the HTTP protocol,
944-
unless you tunnel the RMI traffic. RMI is a fairly heavy-weight protocol, in that
945-
it supports full-object serialization, which is important when you use a complex data model
938+
unless you tunnel the RMI traffic. RMI is a fairly heavy-weight protocol, in that it
939+
supports full-object serialization, which is important when you use a complex data model
946940
that needs serialization over the wire. However, RMI-JRMP is tied to Java clients. It is
947941
a Java-to-Java remoting solution.
948942

@@ -967,8 +961,8 @@ technologies.
967961
Last but not least, EJB has an advantage over RMI, in that it supports standard
968962
role-based authentication and authorization and remote transaction propagation. It is
969963
possible to get RMI invokers or HTTP invokers to support security context propagation as
970-
well, although this is not provided by core Spring. Spring offers only appropriate hooks for
971-
plugging in third-party or custom solutions.
964+
well, although this is not provided by core Spring. Spring offers only appropriate hooks
965+
for plugging in third-party or custom solutions.
972966

973967

974968

@@ -1608,6 +1602,19 @@ implementation of Spring's `PlatformTransactionManager` for JMS (the cunningly n
16081602
`JmsTransactionManager`). This allows for seamless integration of JMS as a transactional
16091603
resource into Spring's transaction management mechanisms.
16101604

1605+
[NOTE]
1606+
====
1607+
As of Spring Framework 5, Spring's JMS package fully supports JMS 2.0 and requires the
1608+
JMS 2.0 API to be present at runtime. We recommend the use of a JMS 2.0 compatible provider.
1609+
1610+
If you happen to use an older message broker in your system, you may try upgrading to a
1611+
JMS 2.0 compatible driver for your existing broker generation. Alternatively, you may also
1612+
try to run against a JMS 1.1 based driver, simply putting the JMS 2.0 API jar on the
1613+
classpath but only using JMS 1.1 compatible API against your driver. Spring's JMS support
1614+
adheres to JMS 1.1 conventions by default, so with corresponding configuration it does
1615+
support such a scenario. However, please consider this for transition scenarios only.
1616+
====
1617+
16111618

16121619

16131620
[[jms-using]]

0 commit comments

Comments
 (0)