<div dir="ltr"><div class="gmail_extra"><div><div class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div></div></div></div></div></div>
<br><div class="gmail_quote">2015-08-26 11:07 GMT+02:00 Nigel Deakin <span dir="ltr">&lt;<a href="mailto:nigel.deakin@oracle.com" target="_blank">nigel.deakin@oracle.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">(Tidying up the top-posting...)<br>
<br>
Romain Manni-Bucau:<br>
&gt; ...I see it really nice to not rely only on annotation - and aligned with<span class=""><br>
&gt; most specs - since sometimes you just want to either be able to rely on a<br>
&gt; loop or a custom config to register your listeners. Annotations are too<br>
&gt; rigid for such cases.<br>
<br></span>
Nigel:<span class=""><br>
&gt; Obviously, if users don&#39;t want to use CDI (or MDBs, which are also<br>
&gt; declarative), then they would use the  normal JMS API. The existing<br>
&gt; API to register an async message listener isn&#39;t good enough,<br>
&gt; and we may improve it in JMS 2.1, but that&#39;s not something that<br>
&gt; I&#39;d want to bother the people on cdi-dev with.<br>
<br></span>
Romain Manni-Bucau:<span class=""><br>
&gt; Integrating it in CDI lifecycle through an event allow CDI users to still<br>
&gt; use it in the right phase of the container boot so it is still important<br>
&gt; IMO and avoid all users to have their own custom listener for it -<br>
&gt; @Initialized(AppScoped.class). Also allow to enrich the API through the event<br>
&gt; itself making things smoother IMO.<br>
<br></span>
Nigel:<span class=""><br>
&gt; I&#39;m sorry I don&#39;t understand you.<br>
&gt; I thought you were asking about an API which does not use annotation.<br>
<br></span>
Romain Manni-Bucau:<span class=""><br>
&gt; Both are needed (like websocket spec). Annotation one is nice for fully business<br>
&gt; code and/or simple libs but relying on CDI allows to simplify the wiring since you<br>
&gt; can reuse CDI beans under the hood ie have an implicit connection factory if<br>
&gt; there is a single one etc which is not possible in fully SE context.<br>
<br></span>
Can you explain the distinction you&#39;re making here? You seem to be suggesting two alternatives, using &quot;annotation&quot; and &quot;relying on CDI&quot;. What would an application which uses CDI but which doesn&#39;t use annotation look like?<span class=""><font color="#888888"><br>
<br></font></span></blockquote><div><br></div><div>The sample I gave before with the JmsStart event basically:</div><div><br></div><div><br></div><div>public class JmsRegistrar {</div><div>    @Inject</div><div>    @JmsConnectionFactory(...)</div><div>    private ConnectionFactory factory;</div><div><br></div><div>    @Inject</div><div>    @JmsQueue(...)</div><div>    private Queue queue;</div><div><br></div><div>    public void startJms(@Observes JmsStart start) {</div><div>        start.withFactory(factory) // withFactory should be optional if only 1 bean matches it</div><div>               .register(MyCdiTypedListener.class) // with defaults for all potential config</div><div>                   .listenOn(queue)</div><div>               .register(MyCdiTypedListener2.class, new MyLiteral())</div><div>                    .withMaxSessions(10)</div><div>                    .listenOn(Queue.class, new QueueLiteral(...))</div><div>                    ......;</div><div>    }</div><div>}</div><div><br></div><div><br></div><div>The power of it appears when you have a config injection in JmsRegistrar you can iterate over to get the list of listener for instance.</div><div><br></div><div>Also JMS resources can be decorated and referenced from qualifiers instead of instances thanks to CDI.</div><div><br></div><div>It doesnt prevent the app to use @JmxListener somewhere else if the listener doesnt need any input/config to be registered.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><font color="#888888">
Nigel<br>
</font></span></blockquote></div><br></div></div>