activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher L. Shannon (Confluence)" <conflue...@apache.org>
Subject [CONF] Apache ActiveMQ > JNDI Support
Date Tue, 23 Feb 2016 13:35:08 GMT
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

<base href="https://cwiki.apache.org/confluence"> 
<title>Message Title</title>  
<style type="text/css">@media only screen and (max-device-width: 480px) {.mobile-only
{
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    line-height: normal !important;
    font-size: inherit !important;
    mso-hide: all;
}

.desktop-only {
    display: none !important;
}

/* iPhone 3GS fix for unwanted 20px right margin */
body {
    min-width: 100% !important;
    padding: 0;
    margin: 0;
}

#center-content-table {
    max-width: none;
!important;
}

#header-pattern-container {
    padding: 10px 10px 10px 10px !important;
    line-height: 20px !important;
}

#header-avatar-image-container {
    padding-right: 8px !important;
}

#email-content-container {
    padding: 0 !important;
}

.mobile-expand {
    border-radius: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
    padding-left: 26px !important;
}

.mobile-resize-text {
    font-size: 16px !important;
    line-height: 22px !important;
}

#page-title-pattern-header {
    font-size: 20px !important;
    line-height: 28px !important;
}

#page-title-pattern-icon-image-container-cell {
    padding-top: 7px !important;
}

#inline-user-pattern {
    display: block !important;
}

#inline-user-pattern-avatar {
    padding-top: 3px !important;
}

.contextual-area-pattern {
    border-bottom: 1px solid #ccc !important;
    padding: 15px 10px 0 10px !important;
}

.users-involved-pattern-column-table {
    width: 100% !important;
}

.users-involved-pattern-avatar-table-cell {
    padding: 3px 5px 5px 0 !important;
}

.users-involved-pattern-column-container {
    padding-right: 0 !important;
}

.contextual-excerpt-pattern, #users-involved-pattern {
    border: 0 !important;
}

/** Aui Typography upsized for mobile **/
#content-excerpt-pattern-container, #contextual-excerpt-pattern-text-container {
    font-size: 16px !important;
    line-height: 22px !important;
}

#content-excerpt-pattern-container h1, #contextual-excerpt-pattern-text-container h1 {
    font-size: 24px !important;
    line-height: 28px !important;
}

#content-excerpt-pattern-container h2, #contextual-excerpt-pattern-text-container h2 {
    font-size: 20px !important;
    line-height: 28px !important;
}

#content-excerpt-pattern-container h3, #contextual-excerpt-pattern-text-container h3 {
    font-size: 18px !important;
    line-height: 24px !important;
}

#content-excerpt-pattern-container h4, #contextual-excerpt-pattern-text-container h4 {
    font-size: 16px !important;
    line-height: 22px !important;
}

#content-excerpt-pattern-container h5, #contextual-excerpt-pattern-text-container h5 {
    font-size: 14px !important;
    line-height: 20px !important;
}

#content-excerpt-pattern-container h6, #contextual-excerpt-pattern-text-container h6 {
    font-size: 14px !important;
    line-height: 20px !important;
}

.user-mention {
    line-height: 18px !important;
}

/** Aui Typography end **/

/* Show appropriate footer logo on mobile, display links vertically */
#footer-pattern {
    padding: 15px 10px !important;
}

#footer-pattern-logo-desktop-container {
    padding: 0 !important;
}

#footer-pattern-logo-desktop {
    width: 0 !important;
    height: 0 !important;
}

#footer-pattern-logo-mobile {
    padding-top: 10px !important;
    width: 30px !important;
    height: 27px !important;
    display: inline !important;
}

#footer-pattern-text {
    display: block !important;
}

#footer-pattern-links-container {
    line-height: 0 !important;
}

.footer-pattern-links.mobile-resize-text,
.footer-pattern-links.mobile-resize-text,
#footer-pattern-text.mobile-resize-text,
#footer-pattern-links-container.no-footer-links {
    font-size: 14px !important;
    line-height: 20px !important;
}

.footer-link {
    display: block !important;
}

#footer-pattern-links-container table {
    display: inline-block !important;
    float: none !important;
}

#footer-pattern-links-container, #footer-pattern-text {
    text-align: center !important;
}

#footer-pattern-links {
    padding-bottom: 5px !important;
}

/** Team Calendar overrides, these should be removed when notifications are updated in Team
Calendars. For now CSS
    overrides are being used because the structure of the content can't change without rereleasing
the plugin */
.mail-calendar-container .day-header + table tr td:first-child {
    vertical-align: top !important;
    padding-top: 5px !important;
}}
@media (min-width: 900px) {#center-content-table { width: 900px; }}
@media all {#outlook a {
    padding: 0;
}

/* Force Outlook to provide a "view in browser" menu link. */
/* Prevent Webkit and Windows Mobile platforms from changing default font sizes.*/
body {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

.ExternalClass {
    width: 100%;
}

/* Force Hotmail to display emails at full width */
#background-table {
    margin: 0;
    padding: 0;
    width: 100% !important;
}

/* Needed to override highlighting on date and time links in iOS */
.grey a {
    color: #707070;
    text-decoration: none;
}/* These styles are appended to the head element of a notification in order to prevent Apple
Mail and similar
   clients from underlining the due dates with a blue hyperlink */
/* a lozenge outside an inline task should always be #333, lozenges inside an inline task
should be
   colored according to their upcoming due dates, a completed task date lozenge or deleted
task date
   lozenge should always be #707070 */
.date-time-lozenge a {color: #333333; text-decoration: none; }
.inline-task-text-container .date-time-lozenge.date-upcoming a {color: #DF6F00; text-decoration:
none; }
.inline-task-text-container .date-time-lozenge.date-past a {color: #D04437; text-decoration:
none; }
.inline-task-text-container.content-deleted-color .date-time-lozenge a,
.inline-task-text-container.checked .date-time-lozenge a {
    color: #707070; text-decoration: none;
}}
</style> 
</head>
<body>
<table id="background-table" cellpadding="0" cellspacing="0" width="100%" style="border-collapse:
collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #333; background-color: #f5f5f5">

<tbody> 
<tr> 
<td id="header-pattern-container" style="padding: 0px; border-collapse: collapse; padding:
10px 20px"> 
<table id="header-pattern" cellspacing="0" cellpadding="0" border="0" style="border-collapse:
collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #333"> 
<tbody> 
<tr> 
<td id="header-avatar-image-container" valign="top" style="padding: 0px; border-collapse:
collapse; vertical-align: top; width: 32px; padding-right: 9px"><a href="https://cwiki.apache.org/confluence/display/~cshannon?src=mail&amp;src.mail.timestamp=1456234508002&amp;src.mail.notification=com.atlassian.confluence.plugins.confluence-content-notifications-plugin%3Apage-edited-notification&amp;src.mail.recipient=8aa980874e36a1eb014e36a2a6263ca9"
style="color: #3b73af; text-decoration: none"><img id="header-avatar-image" class="image_fix"
src="cid:avatar_fd1b516a2c27c311002afaa8418027f4" height="32" width="32" border="0" style="border-radius:
3px; vertical-align: top"></a></td>
<td id="header-text-container" valign="middle" style="padding: 0px; border-collapse: collapse;
vertical-align: middle; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px;
mso-line-height-rule: exactly; mso-text-raise: 1px">Christopher L. Shannon <strong>edited</strong>
a page</td> 
</tr> 
</tbody> 
</table> </td> 
</tr> 
<!-- End Header pattern --> 
<tr> 
<td id="email-content-container" style="padding: 0px; border-collapse: collapse; padding:
0 20px"> 
<table id="email-content-table" cellspacing="0" cellpadding="0" border="0" width="100%"
style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #333;
border-spacing: 0; border-collapse: separate"> 
<tbody> 
<tr> 
<td class="email-content-rounded-top mobile-expand" style="padding: 0px; border-collapse:
collapse; color: #fff; padding: 0 15px 0 16px; height: 15px; background-color: #fff; border-left:
1px solid #ccc; border-top: 1px solid #ccc; border-right: 1px solid #ccc; border-bottom: 0;
border-top-right-radius: 5px; border-top-left-radius: 5px">&nbsp;</td> 
</tr> 
<tr> 
<td class="email-content-main mobile-expand" style="padding: 0px; border-collapse: collapse;
border-left: 1px solid #ccc; border-right: 1px solid #ccc; border-top: 0; border-bottom: 0;
padding: 0 15px 15px 16px; background-color: #fff"> 
<table id="page-title-pattern" cellspacing="0" cellpadding="0" border="0" width="100%"
style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #333">

<tbody> 
<tr> 
<td id="page-title-pattern-icon-image-container" valign="top" style="padding: 0px; border-collapse:
collapse; width: 16px; vertical-align: top"> 
<table cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace:
0pt; mso-table-rspace: 0pt; color: #333"> 
<tbody> 
<tr> 
<td id="page-title-pattern-icon-image-container-cell" style="padding: 0px; border-collapse:
collapse; width: 16px; padding: 9px 8px 0px 0px; mso-text-raise: 5px; mso-line-height-rule:
exactly"><a href="https://cwiki.apache.org/confluence/display/ACTIVEMQ/JNDI+Support?src=mail&amp;src.mail.timestamp=1456234508002&amp;src.mail.notification=com.atlassian.confluence.plugins.confluence-content-notifications-plugin%3Apage-edited-notification&amp;src.mail.recipient=8aa980874e36a1eb014e36a2a6263ca9&amp;src.mail.action=view"
title="page icon" style="vertical-align: top;; color: #3b73af; text-decoration: none"><img
style="vertical-align: top; display: block;" src="cid:page-icon" alt="page icon" title="page
icon" height="16" width="16" border="0"></a></td> 
</tr> 
</tbody> 
</table> </td>
<td style="vertical-align: top;; padding: 0px; border-collapse: collapse; padding-right:
5px; font-size: 20px; line-height: 30px; mso-line-height-rule: exactly" id="page-title-pattern-header-container"><span
id="page-title-pattern-header" style="font-family: Arial, sans-serif; padding: 0; font-size:
20px; line-height: 30px; mso-text-raise: 2px; mso-line-height-rule: exactly; vertical-align:
middle"><a href="https://cwiki.apache.org/confluence/display/ACTIVEMQ/JNDI+Support?src=mail&amp;src.mail.timestamp=1456234508002&amp;src.mail.notification=com.atlassian.confluence.plugins.confluence-content-notifications-plugin%3Apage-edited-notification&amp;src.mail.recipient=8aa980874e36a1eb014e36a2a6263ca9&amp;src.mail.action=view"
title="JNDI Support" style="color: #3b73af; text-decoration: none">JNDI Support</a></span></td>

</tr> 
</tbody> 
</table> </td> 
</tr> 
<tr> 
<td class="email-content-main mobile-expand" style="padding: 0px; border-collapse: collapse;
border-left: 1px solid #ccc; border-right: 1px solid #ccc; border-top: 0; border-bottom: 0;
padding: 0 15px 15px 16px; background-color: #fff"> 
<table class="content-excerpt-pattern" cellspacing="0" cellpadding="0" border="0" width="100%"
style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #333;
font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule:
exactly; mso-text-raise: 1px"> 
<tbody> 
<tr> 
<td class="content-excerpt-pattern-container mobile-resize-text " style="padding: 0px;
border-collapse: collapse; padding: 0 0 0 24px"> <p class="diff-context-placeholder"
style="margin: 10px 0 0 0; margin-top: 0">...</p> <p class="diff-block-context"
style="margin: 10px 0 0 0">For example if you place this <a href="http://svn.apache.org/repos/asf/activemq/trunk/activemq-unit-tests/src/test/resources/jndi.properties"
class="external-link" rel="nofollow" style="color: #3b73af; text-decoration: none">jndi.properties</a>
file on your classpath, you can look inside the InitialContext and lookup ConnectionFactory
objects and Destinations etc.</p> <span class="diff-html-removed" style="font-size:
100%; background-color: #ffe7e7; text-decoration: line-through;">{snippet:id=jndi|lang=none|url=activemq/trunk/activemq-unit-tests/src/test/resources/jndi.properties}</span>

<table class="diff-macro diff-html-removed diff-block-target" style="background-color:
#f0f0f0;border: 1px solid #dddddd;margin: 10px 1px;padding: 0 2px 2px;width: 100%;background-color:
#ffe7e7;border-color: #df9898;; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace:
0pt; color: #333"> 
<thead> 
<tr> 
<th class="diff-macro-title" style="background-color: transparent; text-align: left; font-weight:
normal;padding: 5px;"><span class="diff-html-removed" id="removed-diff-0" style="font-size:
100%; background-color: #ffe7e7; text-decoration: line-through;"><span class="icon macro-placeholder-icon"
style="background-color: ;line-height: 20px;"><img src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/images/icons/macrobrowser/macro-placeholder-default.png"
style="padding-right: 5px; vertical-align: text-bottom;"> </span>Wiki Markup</span></th>

</tr> 
</thead> 
<thead> 
<tr> 
<th class="diff-macro-title" style="background-color: transparent; text-align: left; font-weight:
normal;padding: 5px;"><span class="diff-html-added" id="added-diff-0" style="font-size:
100%; background-color: #ddfade;"><span class="icon macro-placeholder-icon" style="background-color:
;line-height: 20px;"><img src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/plugins/servlet/confluence/placeholder/macro-icon?name=code"
style="padding-right: 5px; vertical-align: text-bottom;"> </span>Code Block</span></th>

</tr> 
</thead> 
<tbody> 
<tr> 
<td class="diff-macro-body" style="background-color: #fff;border: 1px solid #dddddd;padding:
10px;; padding: 0px; border-collapse: collapse"> <pre style="margin: 10px 0 0 0; margin-top:
0">
<span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;">java.naming.factory.initial
= org.apache.activemq.jndi.ActiveMQInitialContextFactory

# use the following property to configure the default connector
java.naming.provider.url = vm://localhost

# use the following property to specify the JNDI name the connection factory
# should appear as. 
#connectionFactoryNames = connectionFactory, queueConnectionFactory, topicConnectionFactry

# register some queues in JNDI using the form
# queue.[jndiName] = [physicalName]
queue.MyQueue = example.MyQueue

# register some topics in JNDI using the form
# topic.[jndiName] = [physicalName]
topic.MyTopic = example.MyTopic</span>
</pre> </td> 
</tr> 
</tbody> 
</table> <p class="diff-block-context" style="margin: 10px 0 0 0">You can edit
the jndi.properties file to configure the ActiveMQConnectionFactory's properties such as brokerURL
and whether or not there should be an embedded broker etc. See <a href="/confluence/pages/viewpage.action?pageId=36150"
style="color: #3b73af; text-decoration: none">how to embed a broker in a connection</a>
for more details.</p> <p class="diff-context-placeholder" style="margin: 10px 0 0
0; margin-top: 0">...</p> <p class="diff-block-context" style="margin: 10px 0
0 0">Make sure to add activemq-&lt;version&gt;.jar and spring-1.x.jar to your classpath.
If the libraries are not in the classpath, you will get a "ClassNotFoundException" at runtime.
If you get "ClassNotFoundException", try printing out the classpath and check it is present.
You can also run activeMQ with "-verbose" option to verify the jar was loaded correctly.</p>
<p class="diff-block-context" style="margin: 10px 0 0 0"> <strong>Sample code</strong>
</p> 
<table class="diff-macro diff-block-target" style="background-color: #f0f0f0;border: 1px
solid #dddddd;margin: 10px 1px;padding: 0 2px 2px;width: 100%;; border-collapse: collapse;
mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #333"> 
<thead> 
<tr> 
<th class="diff-macro-title" style="background-color: transparent; text-align: left; font-weight:
normal;padding: 5px;"><span class="icon macro-placeholder-icon" style="background-color:
;line-height: 20px;"><img src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/plugins/servlet/confluence/placeholder/macro-icon?name=code"
style="padding-right: 5px; vertical-align: text-bottom;"> </span>Code Block</th>

</tr> 
</thead> 
<tbody> 
<tr> 
<td class="diff-macro-body" style="background-color: #fff;border: 1px solid #dddddd;padding:
10px;; padding: 0px; border-collapse: collapse"> <pre style="margin: 10px 0 0 0; margin-top:
0">
<span class="diff-html-removed" id="removed-diff-1" style="font-size: 100%; background-color:
#ffe7e7; text-decoration: line-through;">
</span>// create a new intial context, which loads from jndi.properties file
javax.naming.Context ctx = new javax.naming.InitialContext();
// lookup the connection factory
javax.jms.TopicConnectionFactory factory = (javax.jms.TopicConnectionFactory)ctx.lookup("ConnectionFactory");
// create a new TopicConnection for pub/sub messaging
javax.jms.TopicConnection conn = factory.getTopicConnection();
// lookup an existing topic
javax.jms.Topic mytopic = (javax.jms.Topic)ctx.lookup("MyTopic");
// create a new TopicSession for the client
javax.jms.TopicSession session = conn.createTopicSession(false,TopicSession.AUTO_ACKNOWLEDGE);
// create a new subscriber to receive messages
javax.jms.TopicSubscriber subscriber = session.createSubscriber(mytopic);
</pre> </td> 
</tr> 
</tbody> 
</table> <p class="diff-context-placeholder" style="margin: 10px 0 0 0; margin-top:
0">...</p> 
<div class="table-wrap diff-block-target" style="margin: 10px 0 0 0; overflow-x: auto">

<table class="confluenceTable" style="border-collapse: collapse; border: 1px solid #ddd;;
border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #333; border-collapse:
collapse; margin: 10px 0 0 0; overflow-x: auto; margin-top: 0"> 
<tbody> 
<tr> 
<th class="confluenceTh" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em;
text-align: left; vertical-align: top;background-color: #F0F0F0; font-weight: bold;; border:
1px solid #ddd; padding: 7px 10px; vertical-align: top; text-align: left; background-color:
#f0f0f0; font-weight: bold"> <p style="margin: 10px 0 0 0; margin-top: 0; background-color:
#f0f0f0; font-weight: bold">Example recommended by specification</p> </th>

</tr> 
<tr> 
<td class="confluenceTd" style="border: 1px solid #DDD; padding: 5px 7px; min-width: 0.6em;
text-align: left; vertical-align: top;; padding: 0px; border-collapse: collapse; border: 1px
solid #ddd; padding: 7px 10px; vertical-align: top; text-align: left"> 
<table class="diff-macro" style="background-color: #f0f0f0;border: 1px solid #dddddd;margin:
10px 1px;padding: 0 2px 2px;width: 100%;; border-collapse: collapse; mso-table-lspace: 0pt;
mso-table-rspace: 0pt; color: #333"> 
<thead> 
<tr> 
<th class="diff-macro-title" style="background-color: transparent; text-align: left; font-weight:
normal;padding: 5px;"><span class="icon macro-placeholder-icon" style="background-color:
;line-height: 20px;"><img src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/plugins/servlet/confluence/placeholder/macro-icon?name=code"
style="padding-right: 5px; vertical-align: text-bottom;; max-width: none"> </span>Code
Block</th> 
</tr> 
</thead> 
<tbody> 
<tr> 
<td class="diff-macro-body" style="background-color: #fff;border: 1px solid #dddddd;padding:
10px;; padding: 0px; border-collapse: collapse"> <pre style="margin: 10px 0 0 0; margin-top:
0">
<span class="diff-html-removed" id="removed-diff-2" style="font-size: 100%; background-color:
#ffe7e7; text-decoration: line-through;">
</span>Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
props.setProperty(Context.PROVIDER_URL,"tcp://hostname:61616");
javax.naming.Context ctx = new InitialContext(props);||
</pre> </td> 
</tr> 
</tbody> 
</table> </td> 
</tr> 
</tbody> 
</table> 
</div> <p class="diff-context-placeholder" style="margin: 10px 0 0 0; margin-top:
0">...</p> <p class="diff-block-context" style="margin: 10px 0 0 0">e.g. if
you use the following name to lookup into JNDI</p> 
<table class="diff-macro diff-block-target" style="background-color: #f0f0f0;border: 1px
solid #dddddd;margin: 10px 1px;padding: 0 2px 2px;width: 100%;; border-collapse: collapse;
mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #333"> 
<thead> 
<tr> 
<th class="diff-macro-title" style="background-color: transparent; text-align: left; font-weight:
normal;padding: 5px;"><span class="icon macro-placeholder-icon" style="background-color:
;line-height: 20px;"><img src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/plugins/servlet/confluence/placeholder/macro-icon?name=code"
style="padding-right: 5px; vertical-align: text-bottom;"> </span>Code Block</th>

</tr> 
</thead> 
<tbody> 
<tr> 
<td class="diff-macro-body" style="background-color: #fff;border: 1px solid #dddddd;padding:
10px;; padding: 0px; border-collapse: collapse"> <pre style="margin: 10px 0 0 0; margin-top:
0">
<span class="diff-html-removed" id="removed-diff-3" style="font-size: 100%; background-color:
#ffe7e7; text-decoration: line-through;">
</span>dynamicQueues/FOO.BAR
</pre> </td> 
</tr> 
</tbody> 
</table> <p class="diff-block-context" style="margin: 10px 0 0 0">you will get
back an ActiveMQQueue of the name "FOO.BAR".</p> <p class="diff-context-placeholder"
style="margin: 10px 0 0 0; margin-top: 0">...</p> <p class="diff-block-context"
style="margin: 10px 0 0 0">If you want to use an embedded broker with your JNDI provider
you can just use the <a href="/confluence/pages/viewpage.action?pageId=36000" style="color:
#3b73af; text-decoration: none">VM Transport</a> to connect to the broker in your
URL. e.g. to create a purely in JVM broker use this URI</p> 
<table class="diff-macro diff-block-target" style="background-color: #f0f0f0;border: 1px
solid #dddddd;margin: 10px 1px;padding: 0 2px 2px;width: 100%;; border-collapse: collapse;
mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #333"> 
<thead> 
<tr> 
<th class="diff-macro-title" style="background-color: transparent; text-align: left; font-weight:
normal;padding: 5px;"><span class="icon macro-placeholder-icon" style="background-color:
;line-height: 20px;"><img src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/plugins/servlet/confluence/placeholder/macro-icon?name=code"
style="padding-right: 5px; vertical-align: text-bottom;"> </span>Code Block</th>

</tr> 
</thead> 
<tbody> 
<tr> 
<td class="diff-macro-body" style="background-color: #fff;border: 1px solid #dddddd;padding:
10px;; padding: 0px; border-collapse: collapse"> <pre style="margin: 10px 0 0 0; margin-top:
0">
<span class="diff-html-removed" id="removed-diff-4" style="font-size: 100%; background-color:
#ffe7e7; text-decoration: line-through;">
</span>vm://locahost
</pre> </td> 
</tr> 
</tbody> 
</table> <p class="diff-block-context" style="margin: 10px 0 0 0">If you want
to customize the broker use something like this</p> 
<table class="diff-macro diff-block-target" style="background-color: #f0f0f0;border: 1px
solid #dddddd;margin: 10px 1px;padding: 0 2px 2px;width: 100%;; border-collapse: collapse;
mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #333"> 
<thead> 
<tr> 
<th class="diff-macro-title" style="background-color: transparent; text-align: left; font-weight:
normal;padding: 5px;"><span class="icon macro-placeholder-icon" style="background-color:
;line-height: 20px;"><img src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/plugins/servlet/confluence/placeholder/macro-icon?name=code"
style="padding-right: 5px; vertical-align: text-bottom;"> </span>Code Block</th>

</tr> 
</thead> 
<tbody> 
<tr> 
<td class="diff-macro-body" style="background-color: #fff;border: 1px solid #dddddd;padding:
10px;; padding: 0px; border-collapse: collapse"> <pre style="margin: 10px 0 0 0; margin-top:
0">
<span class="diff-html-removed" id="removed-diff-5" style="font-size: 100%; background-color:
#ffe7e7; text-decoration: line-through;">
</span>vm:broker:(tcp://localhost:61616)
</pre> </td> 
</tr> 
</tbody> 
</table> <p class="diff-context-placeholder" style="margin: 10px 0 0 0; margin-top:
0">...</p> <p class="diff-block-context" style="margin: 10px 0 0 0">Once you
have configured JNDI on the classpath you can run any normal JMS application such as the following
<a href="http://svn.apache.org/repos/asf/incubator/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/demo/SimpleProducer.java"
class="external-link" rel="nofollow" style="color: #3b73af; text-decoration: none">example</a>.
Notice that the Java code just uses pure JMS APIs and is not in any way ActiveMQ specific</p>
<span class="diff-html-removed" style="font-size: 100%; background-color: #ffe7e7; text-decoration:
line-through;">{snippet:id=demo|lang=java|url=activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/demo/SimpleProducer.java}</span>

<table class="diff-macro diff-html-removed diff-block-target" style="background-color:
#f0f0f0;border: 1px solid #dddddd;margin: 10px 1px;padding: 0 2px 2px;width: 100%;background-color:
#ffe7e7;border-color: #df9898;; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace:
0pt; color: #333"> 
<thead> 
<tr> 
<th class="diff-macro-title" style="background-color: transparent; text-align: left; font-weight:
normal;padding: 5px;"><span class="diff-html-removed" id="removed-diff-6" style="font-size:
100%; background-color: #ffe7e7; text-decoration: line-through;"><span class="icon macro-placeholder-icon"
style="background-color: ;line-height: 20px;"><img src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/images/icons/macrobrowser/macro-placeholder-default.png"
style="padding-right: 5px; vertical-align: text-bottom;"> </span>Wiki Markup</span></th>

</tr> 
</thead> 
<thead> 
<tr> 
<th class="diff-macro-title" style="background-color: transparent; text-align: left; font-weight:
normal;padding: 5px;"><span class="diff-html-added" id="added-diff-1" style="font-size:
100%; background-color: #ddfade;"><span class="icon macro-placeholder-icon" style="background-color:
;line-height: 20px;"><img src="https://cwiki.apache.org/confluence/s/en_GB/5982/f2b47fb3d636c8bc9fd0b11c0ec6d0ae18646be7.1/_/plugins/servlet/confluence/placeholder/macro-icon?name=code"
style="padding-right: 5px; vertical-align: text-bottom;"> </span>Code Block</span></th>

</tr> 
</thead> 
<tbody> 
<tr> 
<td class="diff-macro-properties" style="background-color: #fafafa; padding: 0 0 0 5px;
font-size: 12px; text-align: left;padding: 0; border: 1px solid #dddddd;; padding: 0px; border-collapse:
collapse"> 
<table style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt;
color: #333"> 
<tbody> 
<tr> 
<td style="background-color: #fafafa; padding: 0 0 0 5px; font-size: 12px; text-align:
left;; padding: 0px; border-collapse: collapse"><span class="diff-html-added" style="font-size:
100%; background-color: #ddfade;">language</span></td> 
<td style="background-color: #fafafa; padding: 0 0 0 5px; font-size: 12px; text-align:
left;; padding: 0px; border-collapse: collapse"><span class="diff-html-added" style="font-size:
100%; background-color: #ddfade;">java</span></td> 
</tr> 
</tbody> 
</table> </td> 
</tr> 
</tbody> 
<tbody> 
<tr> 
<td class="diff-macro-body" style="background-color: #fff;border: 1px solid #dddddd;padding:
10px;; padding: 0px; border-collapse: collapse"> <pre style="margin: 10px 0 0 0; margin-top:
0">
<span class="diff-html-added" style="font-size: 100%; background-color: #ddfade;">/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * The SimpleQueueSender class consists only of a main method,
 * which sends several messages to a queue.
 *
 * Run this program in conjunction with SimpleQueueReceiver.
 * Specify a queue name on the command line when you run the
 * program.  By default, the program sends one message.  Specify
 * a number after the queue name to send that number of messages.
 */
package org.apache.activemq.demo;
// START SNIPPET: demo
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * A simple polymorphic JMS producer which can work with Queues or Topics which
 * uses JNDI to lookup the JMS connection factory and destination
 * 
 * 
 */
public final class SimpleProducer {
    private static final Logger LOG = LoggerFactory.getLogger(SimpleProducer.class);
    private SimpleProducer() {
    }
    /**
     * @param args the destination name to send to and optionally, the number of
     *                messages to send
     */
    public static void main(String[] args) {
        Context jndiContext = null;
        ConnectionFactory connectionFactory = null;
        Connection connection = null;
        Session session = null;
        Destination destination = null;
        MessageProducer producer = null;
        String destinationName = null;
        final int numMsgs;
        if ((args.length &lt; 1) || (args.length &gt; 2)) {
            LOG.info("Usage: java SimpleProducer &lt;destination-name&gt; [&lt;number-of-messages&gt;]");
            System.exit(1);
        }
        destinationName = args[0];
        LOG.info("Destination name is " + destinationName);
        if (args.length == 2) {
            numMsgs = (new Integer(args[1])).intValue();
        } else {
            numMsgs = 1;
        }
        /*
         * Create a JNDI API InitialContext object
         */
        try {
            jndiContext = new InitialContext();
        } catch (NamingException e) {
            LOG.info("Could not create JNDI API context: " + e.toString());
            System.exit(1);
        }
        /*
         * Look up connection factory and destination.
         */
        try {
            connectionFactory = (ConnectionFactory)jndiContext.lookup("ConnectionFactory");
            destination = (Destination)jndiContext.lookup(destinationName);
        } catch (NamingException e) {
            LOG.info("JNDI API lookup failed: " + e);
            System.exit(1);
        }
        /*
         * Create connection. Create session from connection; false means
         * session is not transacted. Create sender and text message. Send
         * messages, varying text slightly. Send end-of-messages message.
         * Finally, close connection.
         */
        try {
            connection = connectionFactory.createConnection();
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            producer = session.createProducer(destination);
            TextMessage message = session.createTextMessage();
            for (int i = 0; i &lt; numMsgs; i++) {
                message.setText("This is message " + (i + 1));
                LOG.info("Sending message: " + message.getText());
                producer.send(message);
            }
            /*
             * Send a non-text control message indicating end of messages.
             */
            producer.send(session.createMessage());
        } catch (JMSException e) {
            LOG.info("Exception occurred: " + e);
        } finally {
            if (connection != null) {
                try {
                    connection.close();
                } catch (JMSException e) {
                }
            }
        }
    }
}
// END SNIPPET: demo
</span>
</pre> </td> 
</tr> 
</tbody> 
</table> </td> 
</tr> 
</tbody> 
</table> </td> 
</tr> 
<tr> 
<td class="email-content-main mobile-expand action-padding last-row-padding" style="padding:
0px; border-collapse: collapse; border-left: 1px solid #ccc; border-right: 1px solid #ccc;
border-top: 0; border-bottom: 0; padding: 0 15px 15px 16px; background-color: #fff; padding-bottom:
10px; padding-bottom: 10px"> 
<table id="actions-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse:
collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #333; font-family: Arial, sans-serif;
font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px">

<tbody> 
<tr> 
<td id="actions-pattern-container" valign="middle" style="padding: 0px; border-collapse:
collapse; padding: 15px 0 0 24px; vertical-align: middle"> 
<table align="left" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace:
0pt; color: #333"> 
<tbody> 
<tr> 
<td class="actions-pattern-action-icon-container" style="padding: 0px; border-collapse:
collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule:
exactly; mso-text-raise: 0px; vertical-align: middle"><a href="https://cwiki.apache.org/confluence/display/ACTIVEMQ/JNDI+Support?src=mail&amp;src.mail.timestamp=1456234508002&amp;src.mail.notification=com.atlassian.confluence.plugins.confluence-content-notifications-plugin%3Apage-edited-notification&amp;src.mail.recipient=8aa980874e36a1eb014e36a2a6263ca9&amp;src.mail.action=view"
title="View page Icon" style="color: #3b73af; text-decoration: none"><img class="actions-pattern-action-icon-image"
height="16" width="16" border="0" title="View page Icon" src="cid:com.atlassian.confluence.plugins.confluence-email-resources%3Aview-page-email-adg-footer-item%3Aicon"
alt="View page Icon" style="vertical-align: middle"></a></td>
<td class="actions-pattern-action-text-container" style="padding: 0px; border-collapse:
collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule:
exactly; mso-text-raise: 4px; padding-left: 5px; white-space: nowrap"><a href="https://cwiki.apache.org/confluence/display/ACTIVEMQ/JNDI+Support?src=mail&amp;src.mail.timestamp=1456234508002&amp;src.mail.notification=com.atlassian.confluence.plugins.confluence-content-notifications-plugin%3Apage-edited-notification&amp;src.mail.recipient=8aa980874e36a1eb014e36a2a6263ca9&amp;src.mail.action=view"
title="View page" style="color: #3b73af; text-decoration: none">View page</a></td>
<td class="actions-pattern-action-bull" style="padding: 0px; border-collapse: collapse;
font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule:
exactly; mso-text-raise: 4px; color: #999; padding: 0 5px">•</td> 
</tr> 
</tbody> 
</table> 
<table style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt;
color: #333"> 
<tbody> 
<tr> 
<td class="actions-pattern-action-icon-container" style="padding: 0px; border-collapse:
collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule:
exactly; mso-text-raise: 0px; vertical-align: middle"><a href="https://cwiki.apache.org/confluence/plugins/likes/like.action?contentId=35864&amp;src=mail&amp;src.mail.timestamp=1456234508002&amp;src.mail.notification=com.atlassian.confluence.plugins.confluence-content-notifications-plugin%3Apage-edited-notification&amp;src.mail.recipient=8aa980874e36a1eb014e36a2a6263ca9&amp;src.mail.action=like"
title="Like Icon" style="color: #3b73af; text-decoration: none"><img class="actions-pattern-action-icon-image"
height="16" width="16" border="0" title="Like Icon" src="cid:com.atlassian.confluence.plugins.confluence-like%3Aview-email-adg-content-item%3Aicon"
alt="Like Icon" style="vertical-align: middle"></a></td>
<td class="actions-pattern-action-text-container" style="padding: 0px; border-collapse:
collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule:
exactly; mso-text-raise: 4px; padding-left: 5px; white-space: nowrap"><a href="https://cwiki.apache.org/confluence/plugins/likes/like.action?contentId=35864&amp;src=mail&amp;src.mail.timestamp=1456234508002&amp;src.mail.notification=com.atlassian.confluence.plugins.confluence-content-notifications-plugin%3Apage-edited-notification&amp;src.mail.recipient=8aa980874e36a1eb014e36a2a6263ca9&amp;src.mail.action=like"
title="Like" style="color: #3b73af; text-decoration: none">Like</a></td> 
</tr> 
</tbody> 
</table> </td> 
</tr> 
</tbody> 
</table> </td> 
</tr> 
<tr> 
<td class="email-content-rounded-bottom mobile-expand" style="padding: 0px; border-collapse:
collapse; color: #fff; height: 5px; line-height: 5px; padding: 0 15px 0 16px; background-color:
#fff; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; border-top: 0; border-left:
1px solid #ccc; border-bottom: 1px solid #ccc; border-right: 1px solid #ccc; mso-line-height-rule:
exactly">&nbsp;</td> 
</tr> 
</tbody> 
</table> </td> 
</tr> 
<tr> 
<td id="footer-pattern" style="padding: 0px; border-collapse: collapse; padding: 12px 20px">

<table id="footer-pattern-container" cellspacing="0" cellpadding="0" border="0" width="100%"
style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #333">

<tbody> 
<tr> 
<td id="footer-pattern-links-container" width="100%" style="padding: 0px; border-collapse:
collapse; color: #999; font-size: 12px; line-height: 18px; font-family: Arial, sans-serif;
mso-line-height-rule: exactly; mso-text-raise: 2px"> 
<table align="left" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace:
0pt; color: #333; font-size: 12px; line-height: 18px; font-family: Arial, sans-serif; mso-line-height-rule:
exactly; mso-text-raise: 2px"> 
<tbody> 
<tr> 
<td class="footer-pattern-links mobile-resize-text" style="padding: 0px; border-collapse:
collapse"><a href="https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=ACTIVEMQ&amp;src=mail&amp;src.mail.timestamp=1456234508002&amp;src.mail.notification=com.atlassian.confluence.plugins.confluence-content-notifications-plugin%3Apage-edited-notification&amp;src.mail.recipient=8aa980874e36a1eb014e36a2a6263ca9&amp;src.mail.action=stop-watching"
title="" style="color: #3b73af; text-decoration: none">Stop watching space</a></td>
<td class="footer-pattern-links-bull" style="padding: 0px; border-collapse: collapse; padding:
0 5px; color: #999">•</td> 
</tr> 
</tbody> 
</table> 
<table style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt;
color: #333; font-size: 12px; line-height: 18px; font-family: Arial, sans-serif; mso-line-height-rule:
exactly; mso-text-raise: 2px"> 
<tbody> 
<tr> 
<td class="footer-pattern-links mobile-resize-text" style="padding: 0px; border-collapse:
collapse"><a href="https://cwiki.apache.org/confluence/users/editmyemailsettings.action?src=mail&amp;src.mail.timestamp=1456234508002&amp;src.mail.notification=com.atlassian.confluence.plugins.confluence-content-notifications-plugin%3Apage-edited-notification&amp;src.mail.recipient=8aa980874e36a1eb014e36a2a6263ca9&amp;src.mail.action=manage"
title="" style="color: #3b73af; text-decoration: none">Manage notifications</a></td>

</tr> 
</tbody> 
</table> </td>
<td id="footer-pattern-logo-desktop-container" rowspan="2" valign="top" style="padding:
0px; border-collapse: collapse; padding-left: 20px; vertical-align: top"> 
<table style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt;
color: #333"> 
<tbody> 
<tr> 
<td id="footer-pattern-logo-desktop-padding" style="padding: 0px; border-collapse: collapse;
padding-top: 3px"><img id="footer-pattern-logo-desktop" src="cid:footer-desktop-logo"
alt="Confluence logo big" title="Confluence logo big" width="132" height="20" class="image_fix"></td>

</tr> 
</tbody> 
</table> </td> 
</tr> 
<tr> 
<td id="footer-pattern-text" class="mobile-resize-text" width="100%" style="padding: 0px;
border-collapse: collapse; color: #999; font-size: 12px; line-height: 18px; font-family: Arial,
sans-serif; mso-line-height-rule: exactly; mso-text-raise: 2px; display: none">This message
was sent by Atlassian Confluence 5.8.4<br> <img id="footer-pattern-logo-mobile" src="cid:footer-mobile-logo"
alt="" title="" width="0" height="0" style="display: none; mso-hide: all"></td> 
</tr> 
</tbody> 
</table> </td> 
</tr> 
</tbody> 
</table> 
<table id="sealed-section" border="0" cellpadding="0" cellspacing="0" width="0" style="border-collapse:
collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; color: #333; display: none"> 
<tbody> 
<tr> 
<td style="padding: 0px; border-collapse: collapse; border: 0; font-size: 0px; line-height:
0; mso-line-height-rule: exactly"></td> 
</tr> 
</tbody> 
</table>
</body>
</html>
Mime
View raw message