camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel: Book Component Appendix (page edited)
Date Mon, 14 Jul 2008 14:14:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence" />
    <style type="text/css">
    <!--
    body, p, td, table, tr, .bodytext, .stepfield {
	font-family: Verdana, arial, sans-serif;
	font-size: 11px;
	line-height: 16px;
	color: #000000;
	font-weight: normal;
}
#PageContent {
	text-align: left;
	background-color: #fff;
	padding: 0px;
	margin: 0px;
    padding-bottom:20px;
}
/*
** when this stylesheet is used for the Tiny MCE Wysiwyg editor's edit area, we can't
** use an id=PageContent or class=wiki-content, so we must
** set the body style to that used for PageContent, and p to that used for wiki-content.
*/

body {
	margin: 0px;
	padding: 0px;
	text-align: center;
    background-color: #f0f0f0;
}

@media print {

body {
    background-color: #fff;
}

}

.monospaceInput {
    font:12px monospace
}

.wiki-content p, .commentblock p {
    margin: 16px 0px 16px 0px;
    padding: 0px;
}

.wiki-content-preview {
    padding: 5px;
    border-left: 1px solid #3c78b5;
    border-right: 1px solid #3c78b5;
}

ul, ol {
    margin-top: 2px;
    margin-bottom: 2px;
    padding-top: 0px;
    padding-bottom: 0px;
}

pre {
    padding: 0px;
    margin-top: 5px;
    margin-left: 15px;
    margin-bottom: 5px;
    margin-right: 5px;
    text-align: left;
}

.helpheading {
    font-weight: bold;
    background-color: #D0D9BD;
        border-bottom: 1px solid #3c78b5;
        padding: 4px 4px 4px 4px;
        margin: 0px;
        margin-top: 10px;
}
.helpcontent {
        padding: 4px 4px 20px 4px;
    background-color: #f5f7f1;
}

.code {
 	border: 1px dashed #3c78b5;
    font-size: 11px;
	font-family: Courier;
    margin: 10px;
	line-height: 13px;
}

.focusedComment {
    background: #ffffce;
}

.commentBox, .focusedComment {
    padding: 10px;
    margin: 5px 0 5px 0;
    border: 1px #bbb solid;
}

.codeHeader {
    background-color: #f0f0f0;
 	border-bottom: 1px dashed #3c78b5;
    padding: 3px;
	text-align: center;
}

.codeContent {
    text-align: left;
    background-color: #f0f0f0;
    padding: 3px;
}

.preformatted {
 	border: 1px dashed #3c78b5;
    font-size: 11px;
	font-family: Courier;
    margin: 10px;
	line-height: 13px;
}

.preformattedHeader {
    background-color: #f0f0f0;
 	border-bottom: 1px dashed #3c78b5;
    padding: 3px;
	text-align: center;
}

.preformattedContent {
    background-color: #f0f0f0;
    padding: 3px;
}

.panel {
 	border: 1px dashed #3c78b5;
    margin: 10px;
    margin-top: 0px;
}

.panelHeader {
    background-color: #f0f0f0;
 	border-bottom: 1px dashed #3c78b5;
    padding: 3px;
	text-align: center;
}

.panelContent {
    background-color: #f0f0f0;
    padding: 5px;
}

.anonymousAlert {
    background-color: #f0f0f0;
 	border: 1px dashed red;
    font-size: 11px;
    padding: 10px 5px 10px 5px;
    margin: 4px;
	line-height: 13px;
}

.lockAlert {
    background-color: #f0f0f0;
    width: 50%;
 	border: 1px dashed red;
    font-size: 11px;
    padding: 10px 5px 10px 5px;
    margin: 4px;
	line-height: 13px;
}


.code-keyword {
  color: #000091;
  background-color: inherit;
}

.code-object {
  color: #910091;
  background-color: inherit;
}

.code-quote {
  color: #009100;
  background-color: inherit;
}

.code-comment {
  color: #808080;
  background-color: inherit;
}


.code-xml .code-keyword {
  color: inherit;
  font-weight: bold;
}

.code-tag {
  color: #000091;
  background-color: inherit;
}

.breadcrumbs {
    background-color: #f0f0f0;
 	border-color: #3c78b5;
	border-width: 1px 0px 1px 0px;
	border-style: solid;
    font-size: 11px;
    padding: 3px 0px 3px 0px;
}

.navmenu {
    border: 1px solid #ccc;
}

.menuheading {
    font-weight: bold;
    background-color: #f0f0f0;
 	border-bottom: 1px solid #3c78b5;
	padding: 4px 4px 2px 4px;
}

.menuitems {
	padding: 4px 4px 20px 4px;
}

.rightpanel {
    border-left: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
}

#helpheading {
    text-align: left;
    font-weight: bold;
    background-color: #D0D9BD;
 	border-bottom: 1px solid #3c78b5;
	padding: 4px 4px 4px 4px;
	margin: 0px;
}
#helpcontent {
	padding: 4px 4px 4px 4px;
    background-color: #f5f7f1;
}
.helptab-unselected {
    font-weight: bold;
	padding: 5px;
    background-color: #f5f7f1;
}
.helptab-selected {
    font-weight: bold;
    background-color: #D0D9BD;
	padding: 5px;
}
.helptabs {
    margin: 0px;
    background-color: #f5f7f1;
	padding: 5px;
}
.infopanel-heading {
    font-weight: bold;
	padding: 4px 0px 2px 0px;
}

.pagebody {
}

.pageheader {
	padding: 5px 5px 5px 0px;
 	border-bottom: 1px solid #3c78b5;
}

.pagetitle {
	font-size: 22px;
	font-weight: bold;
	font-family: Arial, sans-serif;
	color: #003366;
}

.newpagetitle {
    color: #ccc !important;
}

.steptitle {
	font-size: 18px;
	font-weight: bold;
	font-family: Arial, sans-serif;
	color: #003366;
	margin-bottom: 7px;
}

.substeptitle {
    font-size: 12px;
    font-weight: bold;
    font-family: Arial, sans-serif;
    color: #003366;
    margin: 2px 4px 4px 4px;
    padding: 2px 4px 1px 4px;
}

.stepdesc {
    font-family: Verdana, arial, sans-serif;
	font-size: 11px;
	line-height: 16px;
	font-weight: normal;
    color: #666666;
    margin-top: 7px;
    margin-bottom: 7px;
}

.steplabel {
    font-weight: bold;
    margin-right: 4px;
    color: black;
    float: left;
    width: 15%;
    text-align: right;
}

.stepfield {
    background: #f0f0f0;
    padding: 5px;
}

.submitButtons{
    margin-top:5px;
    text-align:right;
}

.formtitle {
	font-size: 12px;
	font-weight: bold;
	font-family: Arial, sans-serif;
	color: #003366;
}

.sectionbottom {
    border-bottom: 1px solid #3c78b5;
}

.topRow {
    border-top: 2px solid #3c78b5;
}

.tabletitle {
	font-size: 14px;
	font-weight: bold;
	font-family: Arial, sans-serif;
    padding: 3px 0px 2px 0px;
    margin: 8px 4px 2px 0px;
	color: #003366;
	border-bottom: 2px solid #3c78b5;
}
.pagesubheading {
    color: #666666;
    font-size: 10px;
    padding: 0px 0px 5px 0px;
}

HR {
	color: 3c78b5;
	height: 1;
}

A:link, A:visited, A:active, A:hover {
	color: #003366;
}

h1 A:link, h1 A:visited, h1 A:active {
	text-decoration: none;
}

h1 A:hover {
    border-bottom: 1px dotted #003366;
}

.wiki-content > :first-child, .commentblock > :first-child {
    margin-top: 3px;
}

.logocell {
    padding: 10px;
}

input {
	font-family: verdana, geneva, arial, sans-serif;
	font-size: 11px;
	color: #000000;
}

textarea, textarea.editor {
	font-family: verdana, geneva, arial, sans-serif;
	font-size: 11px;
	color: #333333;
}

/* use logoSpaceLink instead.
.spacenametitle {
	font: 21px/31px Impact, Arial, Helvetica;
    font-weight: 100;
    color: #999999;
	margin: 0px;
}
.spacenametitle img {
  margin: 0 0 -4px 0;
}
.spacenametitle a {
    text-decoration: none;
    color: #999999;
}
.spacenametitle a:visited {
    text-decoration: none;
    color: #999999;
}*/

.spacenametitle-printable {
	font: 20px/25px Impact, Arial, Helvetica;
    font-weight: 100;
    color: #999999;
	margin: 0px;
}
.spacenametitle-printable a {
    text-decoration: none;
    color: #999999;
}
.spacenametitle-printable a:visited {
    text-decoration: none;
    color: #999999;
}

.blogDate {
	font-weight: bold;
	text-decoration: none;
	color: black;
}

.blogSurtitle {
    background: #f0f0f0;
 	border: 1px solid #ddd;
	padding: 3px;
	margin: 1px 1px 10px 1px;
}

.blogHeading {
    font-size: 20px;
    line-height: normal;
    font-weight: bold;
    padding: 0px;
    margin: 0px;
}

.blogHeading a {
   text-decoration: none;
   color: black;
}

.endsection {
	align: right;
	color: #666666;
	margin-top: 10px;
}
.endsectionleftnav {
	align: right;
	color: #666666;
	margin-top: 10px;
}

h1 {
	font-size: 24px;
	line-height: normal;
	font-weight: bold;
	background-color: #f0f0f0;
	color: #003366;
 	border-bottom: 1px solid #3c78b5;
	padding: 2px;
	margin: 36px 0px 4px 0px;
}

h2 {
	font-size: 18px;
	line-height: normal;
	font-weight: bold;
	background-color: #f0f0f0;
 	border-bottom: 1px solid #3c78b5;
	padding: 2px;
	margin: 27px 0px 4px 0px;
}

h3 {
	font-size: 14px;
	line-height: normal;
	font-weight: bold;
	background-color: #f0f0f0;
	padding: 2px;
	margin: 21px 0px 4px 0px;
}

h4 {
	font-size: 12px;
	line-height: normal;
	font-weight: bold;
	background-color: #f0f0f0;
	padding: 2px;
	margin: 18px 0px 4px 0px;
}

h4.search {
	font-size: 12px;
	line-height: normal;
	font-weight: normal;
	background-color: #f0f0f0;
	padding: 4px;
	margin: 18px 0px 4px 0px;
}

h5 {
	font-size: 10px;
	line-height: normal;
	font-weight: bold;
	background-color: #f0f0f0;
	padding: 2px;
	margin: 14px 0px 4px 0px;
}

h6 {
	font-size: 8px;
	line-height: normal;
	font-weight: bold;
	background-color: #f0f0f0;
	padding: 2px;
	margin: 14px 0px 4px 0px;
}

.smallfont {
    font-size: 10px;
}
.descfont {
    font-size: 10px;
    color: #666666;
}
.smallerfont {
    font-size: 9px;
}
.smalltext {
    color: #666666;
    font-size: 10px;
}
.smalltext a {
    color: #666666;
}
.smalltext-blue {
    color: #3c78b5;
    font-size: 10px;
}
.surtitle {
    margin-left: 1px;
    margin-bottom: 5px;
    font-size: 14px;
    color: #666666;
}

/* css hack found here:  http://www.fo3nix.pwp.blueyonder.co.uk/tutorials/css/hacks/ */
.navItemOver { font-size: 10px; font-weight: bold; color: #ffffff; background-color: #003366; cursor: hand; voice-family: '\'}\''; voice-family:inherit; cursor: pointer;}
.navItemOver a { color: #ffffff; background-color:#003366; text-decoration: none; }
.navItemOver a:visited { color: #ffffff; background-color:#003366; text-decoration: none; }
.navItemOver a:hover { color: #ffffff; background-color:#003366; text-decoration: none; }
.navItem { font-size: 10px; font-weight: bold; color: #ffffff; background-color: #3c78b5; }
.navItem a { color: #ffffff; text-decoration: none; }
.navItem a:hover { color: #ffffff; text-decoration: none; }
.navItem a:visited { color: #ffffff; text-decoration: none; }

div.padded { padding: 4px; }
div.thickPadded { padding: 10px; }
h3.macrolibrariestitle {
    margin: 0px 0px 0px 0px;
}

div.centered { text-align: center; margin: 10px; }
div.centered table {margin: 0px auto; text-align: left; }

.tableview table {
    margin: 0;
}

.tableview th {
    text-align: left;
    color: #003366;
    font-size: 12px;
    padding: 5px 0px 0px 5px;
    border-bottom: 2px solid #3c78b5;
}
.tableview td {
    text-align: left;
    border-color: #ccc;
    border-width: 0px 0px 1px 0px;
    border-style: solid;
    margin: 0;
    padding: 4px 10px 4px 5px;
}

.grid {
    margin: 2px 0px 5px 0px;
    border-collapse: collapse;
}
.grid th  {
    border: 1px solid #ccc;
    padding: 2px 4px 2px 4px;
    background: #f0f0f0;
    text-align: center;
}
.grid td  {
    border: 1px solid #ccc;
    padding: 3px 4px 3px 4px;
}
.gridHover {
	background-color: #f9f9f9;
}

td.infocell {
    background-color: #f0f0f0;
}
.label {
	font-weight: bold;
	color: #003366;
}

label {
	font-weight: bold;
	color: #003366;
}

.error {
	background-color: #fcc;
}

.errorBox {
	background-color: #fcc;
    border: 1px solid #c00;
    padding: 5px;
    margin: 5px;
}

.errorMessage {
	color: #c00;
}

.success {
	background-color: #dfd;
}

.successBox {
	background-color: #dfd;
    border: 1px solid #090;
    padding: 5px;
    margin-top:5px;
    margin-bottom:5px;
}

blockquote {
	padding-left: 10px;
	padding-right: 10px;
	margin-left: 5px;
	margin-right: 0px;
	border-left: 1px solid #3c78b5;
}

table.confluenceTable
{
    margin: 5px;
    border-collapse: collapse;
}

/* Added as a temporary fix for CONF-4223. The table elements appear to be inheriting the border: none attribute from the sectionMacro class */
table.confluenceTable td.confluenceTd
{
    border-width: 1px;
    border-style: solid;
    border-color: #ccc;
    padding: 3px 4px 3px 4px;
}

/* Added as a temporary fix for CONF-4223. The table elements appear to be inheriting the border: none attribute from the sectionMacro class */
table.confluenceTable th.confluenceTh
{
    border-width: 1px;
    border-style: solid;
    border-color: #ccc;
    padding: 3px 4px 3px 4px;
    background-color: #f0f0f0;
    text-align: center;
}

td.confluenceTd
{
    border-width: 1px;
    border-style: solid;
    border-color: #ccc;
    padding: 3px 4px 3px 4px;
}

th.confluenceTh
{
    border-width: 1px;
    border-style: solid;
    border-color: #ccc;
    padding: 3px 4px 3px 4px;
    background-color: #f0f0f0;
    text-align: center;
}

DIV.small {
	font-size: 9px;
}

H1.pagename {
	margin-top: 0px;
}

IMG.inline  {}

.loginform {
    margin: 5px;
    border: 1px solid #ccc;
}

/* The text how the "This is a preview" comment should be shown. */
.previewnote { text-align: center;
                font-size: 11px;
                    color: red; }

/* How the preview content should be shown */
.previewcontent { background: #E0E0E0; }

/* How the system messages should be shown (DisplayMessage.jsp) */
.messagecontent { background: #E0E0E0; }

/* How the "This page has been modified..." -comment should be shown. */
.conflictnote { }

.createlink {
    color: maroon;
}
a.createlink {
    color: maroon;
}
.templateparameter {
    font-size: 9px;
    color: darkblue;
}

.diffadded {
    background: #ddffdd;
    padding: 1px 1px 1px 4px;
	border-left: 4px solid darkgreen;
}
.diffdeleted {
    color: #999;
    background: #ffdddd;
    padding: 1px 1px 1px 4px;
	border-left: 4px solid darkred;
}
.diffnochange {
    padding: 1px 1px 1px 4px;
	border-left: 4px solid lightgrey;
}
.differror {
    background: brown;
}
.diff {
    font-family: lucida console, courier new, fixed-width;
	font-size: 12px;
	line-height: 14px;
}
.diffaddedchars {
    background-color:#99ff99;
    font-weight:bolder;
}
.diffremovedchars {
    background-color:#ff9999;
    text-decoration: line-through;
    font-weight:bolder;
}

.greybackground {
    background: #f0f0f0
}

.greybox {
 	border: 1px solid #ddd;
	padding: 3px;
	margin: 1px 1px 10px 1px;
}

.borderedGreyBox {
    border: 1px solid #cccccc;
    background-color: #f0f0f0;
    padding: 10px;
}

.greyboxfilled {
 	border: 1px solid #ddd;
    background: #f0f0f0;
    padding: 3px;
	margin: 1px 1px 10px 1px;
}

.navBackgroundBox {
    padding: 5px 5px 5px 5px;
    font-size: 22px;
	font-weight: bold;
	font-family: Arial, sans-serif;
	color: white;
    background: #3c78b5;
    text-decoration: none;
}

.previewBoxTop {
	background-color: #f0f0f0;
    border-width: 1px 1px 0px 1px;
    border-style: solid;
    border-color: #3c78b5;
    padding: 5px;
    margin: 5px 0px 0px 0px;
    text-align: center;
}
.previewContent {
    background-color: #fff;
 	border-color: #3c78b5;
	border-width: 0px 1px 0px 1px;
	border-style: solid;
	padding: 10px;
	margin: 0px;
}
.previewBoxBottom {
	background-color: #f0f0f0;
    border-width: 0px 1px 1px 1px;
    border-style: solid;
    border-color: #3c78b5;
    padding: 5px;
    margin: 0px 0px 5px 0px;
    text-align: center;
}

.functionbox {
    background-color: #f0f0f0;
 	border: 1px solid #3c78b5;
	padding: 3px;
	margin: 1px 1px 10px 1px;
}

.functionbox-greyborder {
    background-color: #f0f0f0;
 	border: 1px solid #ddd;
	padding: 3px;
	margin: 1px 1px 10px 1px;
}

.search-highlight {
    background-color: #ffffcc;
}

/* normal (white) background */
.rowNormal {
    background-color: #ffffff;
 }

/* alternate (pale yellow) background */
.rowAlternate {
    background-color: #f7f7f7;
}

/* used in the list attachments table */
.rowAlternateNoBottomColor {
    background-color: #f7f7f7;
}

.rowAlternateNoBottomNoColor {
}

.rowAlternateNoBottomColor td {
    border-bottom: 0px;
}

.rowAlternateNoBottomNoColor td {
    border-bottom: 0px;
}

/* row highlight (grey) background */
.rowHighlight {
    background-color: #f0f0f0;

}

TD.greenbar {FONT-SIZE: 2px; BACKGROUND: #00df00; BORDER: 1px solid #9c9c9c; PADDING: 0px; }
TD.redbar {FONT-SIZE: 2px; BACKGROUND: #df0000; BORDER: 1px solid #9c9c9c; PADDING: 0px; }
TD.darkredbar {FONT-SIZE: 2px; BACKGROUND: #af0000; BORDER: 1px solid #9c9c9c; PADDING: 0px; }

TR.testpassed {FONT-SIZE: 2px; BACKGROUND: #ddffdd; PADDING: 0px; }
TR.testfailed {FONT-SIZE: 2px; BACKGROUND: #ffdddd; PADDING: 0px; }

.toolbar  {
    margin: 0px;
    border-collapse: collapse;
}

.toolbar td  {
    border: 1px solid #ccc;
    padding: 2px 2px 2px 2px;
    color: #ccc;
}

td.noformatting {
    border-width: 0px;
    border-style: none;
    text-align: center;
	padding: 0px;
}

.commentblock {
    margin: 12px 0 12px 0;
}

/*
 * Divs displaying the license information, if necessary.
 */
.license-eval, .license-none, .license-nonprofit {
    border-top: 1px solid #bbbbbb;
    text-align: center;
    font-size: 10px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
}

.license-eval, .license-none {
    background-color: #ffcccc;
}

.license-eval b, .license-none b {
    color: #990000
}

.license-nonprofit {
    background-color: #ffffff;
}

/*
 * The shadow at the bottom of the page between the main content and the
 * "powered by" section.
 */
.bottomshadow {
    height: 12px;
    background-image: url("$req.contextPath/images/border/border_bottom.gif");
    background-repeat: repeat-x;
}

/*
 * Styling of the operations box
 */
.navmenu .operations li, .navmenu .operations ul {
    list-style: none;
    margin-left: 0;
    padding-left: 0;
}

.navmenu .operations ul {
    margin-bottom: 9px;
}

.navmenu .label {
    font-weight: inherit;
}

/*
 * Styling of ops as a toolbar
 */
.toolbar div {
    display: none;
}

.toolbar .label {
    display: none;
}

.toolbar .operations {
    display: block;
}

.toolbar .operations ul {
    display: inline;
    list-style: none;
    margin-left: 10px;
    padding-left: 0;
}

.toolbar .operations li {
    list-style: none;
    display: inline;
}

/* list page navigational tabs */
#foldertab {
padding: 3px 0px 3px 8px;
margin-left: 0;
border-bottom: 1px solid #3c78b5;
font: bold 11px Verdana, sans-serif;
}

#foldertab li {
list-style: none;
margin: 0;
display: inline;
}

#foldertab li a {
padding: 3px 0.5em;
margin-left: 3px;
border: 1px solid #3c78b5;
border-bottom: none;
background: #3c78b5;
text-decoration: none;
}

#foldertab li a:link { color: #ffffff; }
#foldertab li a:visited { color: #ffffff; }

#foldertab li a:hover {
color: #ffffff;
background: #003366;
border-color: #003366;
}

#foldertab li a.current {
background: white;
border-bottom: 1px solid white;
color: black;
}

#foldertab li a.current:link { color: black; }
#foldertab li a.current:visited { color: black; }
#foldertab li a.current:hover {
background: white;
border-bottom: 1px solid white;
color: black;
}

/* alphabet list */
ul#squaretab {
margin-left: 0;
padding-left: 0;
white-space: nowrap;
font: bold 8px Verdana, sans-serif;
}

#squaretab li {
display: inline;
list-style-type: none;
}

#squaretab a {
padding: 2px 6px;
border: 1px solid #3c78b5;
}

#squaretab a:link, #squaretab a:visited {
color: #fff;
background-color: #3c78b5;
text-decoration: none;
}

#squaretab a:hover {
color: #ffffff;
background-color: #003366;
border-color: #003366;
text-decoration: none;
}

#squaretab li a#current {
background: white;
color: black;
}

.blogcalendar * {
    font-family:verdana, arial, sans-serif;
    font-size:x-small;
    font-weight:normal;
    line-height:140%;
    padding:2px;
}


table.blogcalendar {
    border: 1px solid #3c78b5;
}

.blogcalendar th.calendarhead, a.calendarhead {
    font-size:x-small;
    font-weight:bold;
    padding:2px;
    text-transform:uppercase;
    background-color: #3c78b5;
    color: #ffffff;
    letter-spacing: .3em;
    text-transform: uppercase;
}

.calendarhead:visited {color: white;}
.calendarhead:active {color: white;}
.calendarhead:hover {color: white;}

.blogcalendar th {
    font-size:x-small;
    font-weight:bold;
    padding:2px;
    background-color:#f0f0f0;
}

.blogcalendar td {
    font-size:x-small;
    font-weight:normal;
}

.searchGroup { padding: 0 0 10px 0; background: #f0f0f0; }
.searchGroupHeading { font-size: 10px; font-weight: bold; color: #ffffff; background-color: #3c78b5; padding: 2px 4px 1px 4px; }
.searchItem { padding: 1px 4px 1px 4px; }
.searchItemSelected { padding: 1px 4px 1px 4px; font-weight: bold; background: #ddd; }

/* permissions page styles */
.permissionHeading {
    border-bottom: #bbb; border-width: 0 0 1px 0; border-style: solid; font-size: 16px; text-align: left;
}
.permissionTab {
    border-width: 0 0 0 1px; border-style: solid; background: #3c78b5; color: #ffffff; font-size: 10px;
}
.permissionSuperTab {
    border-width: 0 0 0 1px; border-style: solid; background: #003366; color: #ffffff;
}
.permissionCell {
    border-left: #bbb; border-width: 0 0 0 1px; border-style: solid;
}

/* warning panel */
.warningPanel { background: #FFFFCE; border:#F0C000 1px solid; padding: 8px; margin: 10px; }
/* alert panel */
.alertPanel { background: #FFCCCC; border:#C00 1px solid; padding: 8px; margin: 10px; }
/* info panel */
.infoPanel { background: #D8E4F1; border:#3c78b5 1px solid; padding: 8px; margin: 10px; }

/* side menu highlighting (e.g. space content screen) */
.optionPadded { padding: 2px; }
.optionSelected { background-color: #ffffcc; padding: 2px; border: 1px solid #ddd; margin: -1px; }
.optionSelected a { font-weight: bold; text-decoration: none; color: black; }

/* information macros */
.noteMacro { border-style: solid; border-width: 1px; border-color: #F0C000; background-color: #FFFFCE; text-align:left; margin-top: 5px; margin-bottom: 5px}
.warningMacro { border-style: solid; border-width: 1px; border-color: #c00; background-color: #fcc; text-align:left; margin-top: 5px; margin-bottom: 5px}
.infoMacro { border-style: solid; border-width: 1px; border-color: #3c78b5; background-color: #D8E4F1; text-align:left; margin-top: 5px; margin-bottom: 5px}
.tipMacro { border-style: solid; border-width: 1px; border-color: #090; background-color: #dfd; text-align:left; margin-top: 5px; margin-bottom: 5px}
.informationMacroPadding { padding: 5px 0 0 5px; }

table.infoMacro td, table.warningMacro td, table.tipMacro td, table.noteMacro td, table.sectionMacro td {
    border: none;
}

table.sectionMacroWithBorder td.columnMacro { border-style: dashed; border-width: 1px; border-color: #cccccc;}

.pagecontent
{
    padding: 10px;
    text-align: left;
}

/* styles for links in the top bar */
.topBarDiv a:link {color: #ffffff;}
.topBarDiv a:visited {color: #ffffff;}
.topBarDiv a:active {color: #ffffff;}
.topBarDiv a:hover {color: #ffffff;}
.topBarDiv {color: #ffffff;}

.topBar {
    background-color: #003366;
}


/* styles for extended operations */
.greyLinks a:link {color: #666666; text-decoration:underline;}
.greyLinks a:visited {color: #666666; text-decoration:underline;}
.greyLinks a:active {color: #666666; text-decoration:underline;}
.greyLinks a:hover {color: #666666; text-decoration:underline;}
.greyLinks {color: #666666; display:block; padding: 10px}

.logoSpaceLink {color: #999999; text-decoration: none}
.logoSpaceLink a:link {color: #999999; text-decoration: none}
.logoSpaceLink a:visited {color: #999999; text-decoration: none}
.logoSpaceLink a:active {color: #999999; text-decoration: none}
.logoSpaceLink a:hover {color: #003366; text-decoration: none}

/* basic panel (basicpanel.vmd) style */
.basicPanelContainer {border: 1px solid #3c78b5; margin-top: 2px; margin-bottom: 8px; width: 100%}
.basicPanelTitle {padding: 5px; margin: 0px; background-color: #f0f0f0; color: black; font-weight: bold;}
.basicPanelBody {padding: 5px; margin: 0px}

.separatorLinks a:link {color: white}
.separatorLinks a:visited {color: white}
.separatorLinks a:active {color: white}

.greynavbar {background-color: #f0f0f0; border-top: 1px solid #3c78b5; margin-top: 2px}

div.headerField {
    float: left;
    width: auto;
    height: 100%;
}

.headerFloat {
    margin-left: auto;
    width: 50%;
}

.headerFloatLeft {
    float: left;
    margin-right: 20px;
    margin-bottom: 10px;
}

#headerRow {
    padding: 10px;
}

div.license-personal {
   background-color: #003366;
   color: #ffffff;
}

div.license-personal a {
   color: #ffffff;
}

.greyFormBox {
    border: 1px solid #cccccc;
    padding: 5px;
}

/* IE automatically adds a margin before and after form tags. Use this style to remove that */
.marginlessForm {
    margin: 0px;
}

.openPageHighlight {
    background-color: #ffffcc;
    padding: 2px;
    border: 1px solid #ddd;
}

.editPageInsertLinks, .editPageInsertLinks a
{
    color: #666666;
    font-weight: bold;
    font-size: 10px;
}

/* Style for label heatmap. */
.top10 a {
    font-weight: bold;
    font-size: 2em;
    color: #003366;
}
.top25 a {
    font-weight: bold;
    font-size: 1.6em;
    color: #003366;
}
.top50 a {
    font-size: 1.4em;
    color: #003366;
}
.top100 a {
    font-size: 1.2em;
    color: #003366;
}

.heatmap {
    list-style:none;
    width: 95%;
    margin: 0px auto;
}

.heatmap a {
    text-decoration:none;
}

.heatmap a:hover {
    text-decoration:underline;
}

.heatmap li {
    display: inline;
}

.minitab {
padding: 3px 0px 3px 8px;
margin-left: 0;
margin-top: 1px;
margin-bottom: 0px;
border-bottom: 1px solid #3c78b5;
font: bold 9px Verdana, sans-serif;
text-decoration: none;
float:none;
}
.selectedminitab {
padding: 3px 0.5em;
margin-left: 3px;
margin-top: 1px;
border: 1px solid #3c78b5;
background: white;
border-bottom: 1px solid white;
color: #000000;
text-decoration: none;
}
.unselectedminitab {
padding: 3px 0.5em;
margin-left: 3px;
margin-top: 1px;
border: 1px solid #3c78b5;
border-bottom: none;
background: #3c78b5;
color: #ffffff;
text-decoration: none;
}

a.unselectedminitab:hover {
color: #ffffff;
background: #003366;
border-color: #003366;
}

a.unselectedminitab:link { color: white; }
a.unselectedminitab:visited { color: white; }

a.selectedminitab:link { color: black; }
a.selectedminitab:visited { color: black; }

.linkerror { background-color: #fcc;}

a.labelOperationLink:link {text-decoration: underline}
a.labelOperationLink:active {text-decoration: underline}
a.labelOperationLink:visited {text-decoration: underline}
a.labelOperationLink:hover {text-decoration: underline}

a.newLabel:link {background-color: #ddffdd}
a.newLabel:active {background-color: #ddffdd}
a.newLabel:visited {background-color: #ddffdd}
a.newLabel:hover {background-color: #ddffdd}

ul.square {list-style-type: square}

.inline-control-link {
    background: #ffc;
    font-size: 9px;
    color: #666;
    padding: 2px;
    text-transform: uppercase;
    text-decoration: none;
}


.inline-control-link a:link {text-decoration: none}
.inline-control-link a:active {text-decoration: none}
.inline-control-link a:visited {text-decoration: none}
.inline-control-link a:hover {text-decoration: none}

.inline-control-link {
    background: #ffc;
    font-size: 9px;
    color: #666;
    padding: 2px;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
}

div.auto_complete {
    width: 350px;
    background: #fff;
}
div.auto_complete ul {
    border: 1px solid #888;
    margin: 0;
    padding: 0;
    width: 100%;
    list-style-type: none;
}
div.auto_complete ul li {
    margin: 0;
    padding: 3px;
}
div.auto_complete ul li.selected {
    background-color: #ffb;
}
div.auto_complete ul strong.highlight {
    color: #800;
    margin: 0;
    padding: 0;
}

/******* Edit Page Styles *******/
.toogleFormDiv{
    border:1px solid #A7A6AA;
    background-color:white;
    padding:5px;
    margin-top: 5px;
}

.toogleInfoDiv{
    border:1px solid #A7A6AA;
    background-color:white;
    display:none;
    padding:5px;
    margin-top: 10px;
}

.inputSection{
    margin-bottom:20px;
}

#editBox{
   border:1px solid lightgray;
   background-color:#F0F0F0;
}

/******* Left Navigation Theme Styles ********/
.leftnav li a {
    text-decoration:none;
    color:white;
    margin:0px;
    display:block;
    padding:2px;
    padding-left:5px;
    background-color: #3c78b5;
    border-top:1px solid #3c78b5;
}

.leftnav li a:active {color:white;}
.leftnav li a:visited {color:white;}
.leftnav li a:hover {background-color: #003366; color:white;}

/* Added by Shaun during i18n */
.replaced
{
    background-color: #33CC66;
}

.topPadding
{
    margin-top: 20px;
}

/* new form style */
.form-block {
    padding: 6px;
}
.form-error-block {
    padding: 6px;
    background: #fcc;
    border-top: #f0f0f0 1px solid;
    border-bottom: #f0f0f0 1px solid;
    margin-bottom: 6px;
    padding: 0 12px 0 12px;
}
.form-element-large {
    font-size: 16px;
    font-weight: bold;
    font-family: Arial, sans-serif;
    color: #003366;
}

.form-element-small {
    font-size: 12px;
    font-weight: bold;
    font-family: Arial, sans-serif;
    color: #003366;
}

.form-header {
    background: lightyellow;
    border-top: #f0f0f0 1px solid;
    border-bottom: #f0f0f0 1px solid;
    margin-bottom: 6px;
    padding: 0 12px 0 12px;
}
.form-header p, .form-block p, .form-error-block p {
    line-height: normal;
    margin: 12px 0 12px 0;
}
.form-example {
    color: #888;
    font-size: 11px;
}
.form-divider {
    border-bottom: #ccc 1px solid;
    margin-bottom: 6px;
}
.form-buttons {
    margin-top: 6px;
    border-top: #ccc 1px solid;
    border-bottom: #ccc 1px solid;
    background: #f0f0f0;
    padding: 10px;
    text-align: center;
}
.form-buttons input {
    width: 100px;
}
.form-block .error {
    padding: 6px;
    margin-bottom: 6px;
}
    -->
    </style>
</head>
<body>

<div id="PageContent">
<table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%"><tr>
<td valign="top" class="pagebody">

    <div class="pageheader">
        <span class="pagetitle">
            Page Edited :
            <a href="http://cwiki.apache.org/confluence/display/CAMEL">CAMEL</a> :
            <a href="http://cwiki.apache.org/confluence/display/CAMEL/Book+Component+Appendix">Book Component Appendix</a>
        </span>
    </div>

     <p>
        <a href="http://cwiki.apache.org/confluence/display/CAMEL/Book+Component+Appendix">Book Component Appendix</a>
        has been edited by             <a href="http://cwiki.apache.org/confluence/display/~davsclaus">Claus Ibsen</a>
            <span class="smallfont">(Jul 14, 2008)</span>.
     </p>
    
     <p>
                 <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=60169&originalVersion=8&revisedVersion=9">(View changes)</a>
     </p>

    <span class="label">Content:</span><br/>
    <div class="greybox wiki-content"><div class="chapter" id="chapter-component-appendix">
<h1><a name="BookComponentAppendix-ComponentAppendix"></a>Component Appendix</h1>

<p>There now follows the documentation on each Camel component.</p>

<h2><a name="BookComponentAppendix-ActiveMQComponent"></a>ActiveMQ Component</h2>

<p>The ActiveMQ component allows messages to be sent to a <span class="nobr"><a href="http://java.sun.com/products/jms/" title="Visit page outside Confluence" rel="nofollow">JMS<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> Queue or Topic; or messages to be consumed from a JMS Queue or Topic using <span class="nobr"><a href="http://activemq.apache.org/" title="The most popular and powerful open source message broker" rel="nofollow">Apache ActiveMQ<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. </p>

<p>This component is based on the <a href="/confluence/display/CAMEL/JMS" title="JMS">JMS Component</a> and uses Spring's JMS support for declarative transactions, using Spring's JmsTemplate for sending and a MessageListenerContainer for consuming.</p>

<p>To use this component make sure you have the activemq.jar or activemq-core.jar on your classpath along with any Camel dependencies such as camel-core.jar, camel-spring.jar and camel-jms.jar.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">activemq:[topic:]destinationName</pre>
</div></div>

<p>So for example to send to queue FOO.BAR you would use</p>

<div class="code"><div class="codeContent">
<pre class="code-java">activemq:FOO.BAR</pre>
</div></div>

<p>You can be completely specific if you wish via</p>

<div class="code"><div class="codeContent">
<pre class="code-java">activemq:queue:FOO.BAR</pre>
</div></div>


<p>If you want to send to a topic called Stocks.Prices then you would use</p>

<div class="code"><div class="codeContent">
<pre class="code-java">activemq:topic:Stocks.Prices</pre>
</div></div>

<h3><a name="BookComponentAppendix-ConfiguringtheConnectionFactory"></a>Configuring the Connection Factory</h3>

<p>The following <span class="nobr"><a href="http://svn.apache.org/repos/asf/activemq/trunk/activemq-camel/src/test/java/org/apache/activemq/camel/component/ActiveMQRouteTest.java" title="Visit page outside Confluence" rel="nofollow">test case<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> shows how to add an ActiveMQComponent to the <a href="/confluence/display/CAMEL/CamelContext" title="CamelContext">CamelContext</a> using the <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-activemq/apidocs/org/apache/camel/component/activemq/ActiveMQComponent.html#activeMQComponent(java.lang.String)" title="Visit page outside Confluence" rel="nofollow">activeMQComponent() method<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> while specifying the <span class="nobr"><a href="http://activemq.apache.org/configuring-transports.html" title="Visit page outside Confluence" rel="nofollow">brokerURL<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> used to connect to ActiveMQ </p>

<div class="code"><div class="codeContent">
<pre class="code-java">camelContext.addComponent(<span class="code-quote">"activemq"</span>, activeMQComponent(<span class="code-quote">"vm:<span class="code-comment">//localhost?broker.persistent=<span class="code-keyword">false</span>"</span>));</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-ConfiguringtheConnectionFactoryusingSpringXML"></a>Configuring the Connection Factory using Spring XML</h3>

<p>You can configure the ActiveMQ broker URL on the ActiveMQComponent as follows</p>

<div class="code"><div class="codeContent">
<pre class="code-xml">&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
       <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd"&gt;

  <span class="code-tag">&lt;camelContext xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>
  <span class="code-tag">&lt;/camelContext&gt;</span>


  <span class="code-tag">&lt;bean id=<span class="code-quote">"activemq"</span> class=<span class="code-quote">"org.apache.activemq.camel.component.ActiveMQComponent"</span>&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"brokerURL"</span> value=<span class="code-quote">"tcp://somehost:61616"</span>/&gt;</span>
  <span class="code-tag">&lt;/bean&gt;</span>

<span class="code-tag">&lt;/beans&gt;</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-InvokingMessageListenerPOJOsinaCamelroute"></a>Invoking MessageListener POJOs in a Camel route</h3>

<p>The ActiveMQ component also providers a helper <a href="/confluence/display/CAMEL/Type+Converter" title="Type Converter">Type Converter</a> from a JMS MessageListener to a <a href="/confluence/display/CAMEL/Processor" title="Processor">Processor</a>. This means that the <a href="/confluence/display/CAMEL/Bean" title="Bean">Bean</a> component is capable of invoking any JMS MessageListener bean directly inside any route.</p>

<p>So for example you can create a MessageListener in JMS like this....</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">public</span> class MyListener <span class="code-keyword">implements</span> MessageListener {
   <span class="code-keyword">public</span> void onMessage(Message jmsMessage) {
       <span class="code-comment">// ...
</span>   }
}</pre>
</div></div>

<p>Then use it in your Camel route as follows</p>
<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"file:<span class="code-comment">//foo/bar"</span>).
</span>  bean(MyListener.class);</pre>
</div></div>

<p>i.e. you can reuse any of the Camel <a href="/confluence/display/CAMEL/Components" title="Components">Components</a> and easily integrate them into your JMS MessageListener POJO!</p>

<h3><a name="BookComponentAppendix-GettingComponentJAR"></a>Getting Component JAR</h3>

<p>The ActiveMQ Camel component is released with the ActiveMQ project itself.</p>

<p>For Maven 2 users you simply just need to add the following dependency to your project.</p>

<div class="code"><div class="codeContent">
<pre class="code-java">&lt;dependency&gt;
  &lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
  &lt;artifactId&gt;activemq-core&lt;/artifactId&gt;
  &lt;version&gt;5.1.0&lt;/version&gt;
&lt;/dependency&gt;</pre>
</div></div>

<p>Alternatively you can download the component jar directly from the Maven repository:</p>

<p><span class="nobr"><a href="http://repo2.maven.org/maven2/org/apache/activemq/activemq-core/5.1.0/activemq-core-5.1.0.jar" title="Visit page outside Confluence" rel="nofollow">activemq-core-5.1.0.jar<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-ActiveMQJournalComponent"></a>ActiveMQ Journal Component</h2>

<p>The ActiveMQ Journal Component allows messages to be stored in a rolling log file and then consumed from that log file.  The journal aggregates and batches up concurrent writes so that to overhead of writing and waiting for the disk sync is relatively constant regardless of how many concurrent writes are being done.  Therefore, this component supports and encourages you to use multiple concurrent producers to the same journal endpoint.</p>

<p>Each journal endpoint uses a different log file and therefore write batching (and the associated performance boost) does not occur between multiple endpoints.</p>

<p>This component only supports 1 active consumer on the endpoint.  After the message is processed by the consumer's processor, the log file is marked and only subsequent messages in the log file will get delivered to consumers.</p>


<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">activemq.journal:directory-name[?options]</pre>
</div></div>

<p>So for example to send to the journal located in the /tmp/data directory you would use</p>

<div class="code"><div class="codeContent">
<pre class="code-java">activemq.journal:/tmp/data</pre>
</div></div>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> syncConsume </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> If set to true, when the journal is marked after a message is consumed, wait till the Operating System has verified the mark   update is safely stored on disk</td>
</tr>
<tr>
<td class='confluenceTd'> syncProduce </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> If set to true, wait till the Operating System has verified the message is safely stored on disk</td>
</tr>
</tbody></table>


<h3><a name="BookComponentAppendix-ExpectedExchangeDataTypes"></a>Expected Exchange Data Types</h3>

<p>The consumer of a Journal endpoint generates <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/impl/DefaultExchange.html" title="Visit page outside Confluence" rel="nofollow">DefaultExchange<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> objects with the <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/Exchange.html#getIn()" title="Visit page outside Confluence" rel="nofollow">in message<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> :</p>
<ul>
	<li><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/Message.html#getHeader(java.lang.String)" title="Visit page outside Confluence" rel="nofollow">header<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> "journal" : set to the endpoint uri of the journal the message came from</li>
	<li><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/Message.html#getHeader(java.lang.String)" title="Visit page outside Confluence" rel="nofollow">header<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> "location" : set to a <span class="nobr"><a href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/kaha/impl/async/Location.html" title="Visit page outside Confluence" rel="nofollow">Location<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> which identifies where the recored was stored on disk</li>
	<li><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/Message.html#getBody()" title="Visit page outside Confluence" rel="nofollow">body<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> : set to <span class="nobr"><a href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/util/ByteSequence.html" title="Visit page outside Confluence" rel="nofollow">ByteSequence<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> which contains the byte array data of the stored message</li>
</ul>


<p>The producer to a Journal endpoint expects an <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/Exchange.html" title="Visit page outside Confluence" rel="nofollow">Exchange<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> with an In message where the body can be converted to a <span class="nobr"><a href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/util/ByteSequence.html" title="Visit page outside Confluence" rel="nofollow">ByteSequence<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> or a byte[].</p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-AMQP"></a>AMQP</h2>

<p>The AMQP component supports the <span class="nobr"><a href="http://www.amqp.org/" title="Visit page outside Confluence" rel="nofollow">AMQP protocol<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> via the <span class="nobr"><a href="http://cwiki.apache.org/qpid/" title="Visit page outside Confluence" rel="nofollow">Qpid<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> project.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">amqp:[queue:][topic:]destinationName[?option1=value[&amp;option2=value2]]</pre>
</div></div>

<p>You can specify all of the various configuration options of the <a href="/confluence/display/CAMEL/JMS" title="JMS">JMS</a> component after the destination name.</p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-AtomComponent"></a>Atom Component</h2>

<p>The <b>atom:</b> component is used for polling atom feeds.</p>

<p>Camel will default poll the feed every 60th seconds.<br/>
<b>Note:</b> The component currently only supports polling (consuming) feeds.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">atom:<span class="code-comment">//atomUri</span></pre>
</div></div>

<p>Where <b>atomUri</b> is the URI to the atom feed to poll. </p>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Property </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> splitEntries </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> If <b>true</b> Camel will poll the feed and for the subsequent polls return each entry poll by poll. If the feed contains 7 entries then Camel will return the first entry on the first poll, the 2nd entry on the next poll, until no more entries where as Camel will do a new update on the feed. If <b>false</b> then Camel will poll a fresh feed on every invocation. </td>
</tr>
<tr>
<td class='confluenceTd'> filter </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'>  Is only used by the split entries to filter the entries to return. Camel will default use the UpdateDateFilter that only return new entries from the feed. So the client consuming from the feed never receives the same entry more than once. The filter will return the entries ordered by the newest last. </td>
</tr>
<tr>
<td class='confluenceTd'> lastUpdate </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> Is only used by the filter, as the starting timestamp for selection never entries (uses the entry.updated timestamp). Syntax format is: <tt>yyyy-MM-ddTHH:MM:ss</tt>. Example: <tt>2007-12-24T17:45:59</tt>. </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.delay </td>
<td class='confluenceTd'> 60000 </td>
<td class='confluenceTd'> Delay in millis between each poll </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.initialDelay </td>
<td class='confluenceTd'> 1000 </td>
<td class='confluenceTd'> Millis before polling starts </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.userFixedDelay </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> <b>true</b> to use fixed delay between pools, otherwise fixed rate is used. See <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html" title="Visit page outside Confluence" rel="nofollow">ScheduledExecutorService<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> in JDK for details. </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Exchangedataformat"></a>Exchange data format</h3>

<p>Camel will set the in body on the returned Exchange with the entries. Depending on the splitEntries flag Camel will either return one Entry or a List&lt;Entry&gt;.</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Option </th>
<th class='confluenceTh'> Value </th>
<th class='confluenceTh'> Behavior </th>
</tr>
<tr>
<td class='confluenceTd'> splitEntries </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'>  Only a single entry from the currently being processed feed is set: <tt>exchange.in.body(Entry)</tt> </td>
</tr>
<tr>
<td class='confluenceTd'> splitEntries </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> The entires list of entries from the feed is set: <tt>exchange.in.body(List&lt;Entry&gt;)</tt> </td>
</tr>
</tbody></table>

<p>Camel will set the Feed object on the in header:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">exchange.in.header(<span class="code-quote">"org.apache.camel.component.atom.feed"</span>, feed)</pre>
</div></div>

<h3><a name="BookComponentAppendix-Samples"></a>Samples</h3>
<p>In this sample we poll James Strahams blog.</p>
<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"atom:<span class="code-comment">//http://macstrac.blogspot.com/feeds/posts/<span class="code-keyword">default</span>"</span>).to(<span class="code-quote">"seda:feeds"</span>);</span></pre>
</div></div>

<p>In this sample we want to filter only good blogs we like to a seda queue. The sample also shows how to setup Camel standalone, not running in any Container or using Spring.</p>
<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-comment">// This is the CamelContext that is the heart of Camel
</span><span class="code-keyword">private</span> CamelContext context;

<span class="code-comment">// We use a simple Hashtable <span class="code-keyword">for</span> our bean registry. For more advanced usage Spring is supported out-of-the-box
</span><span class="code-keyword">private</span> Hashtable beans = <span class="code-keyword">new</span> Hashtable();

<span class="code-comment">// We iniitalize Camel
</span><span class="code-keyword">private</span> void setupCamel() <span class="code-keyword">throws</span> Exception {
    <span class="code-comment">// First we register a blog service in our bean registry
</span>    beans.put(<span class="code-quote">"blogService"</span>, <span class="code-keyword">new</span> BlogService());

    <span class="code-comment">// Then we create the camel context with our bean registry
</span>    context = <span class="code-keyword">new</span> DefaultCamelContext(<span class="code-keyword">new</span> CamelInitialContextFactory().getInitialContext(beans));

    <span class="code-comment">// Then we add all the routes we need using the route builder DSL syntax
</span>    context.addRoutes(createRouteBuilder());

    <span class="code-comment">// And <span class="code-keyword">finally</span> we must start Camel to let the magic routing begins
</span>    context.start();
}

/**
 * This is the route builder where we create our routes in the advanced Camel DSL syntax
 */
<span class="code-keyword">protected</span> RouteBuilder createRouteBuilder() <span class="code-keyword">throws</span> Exception {
    <span class="code-keyword">return</span> <span class="code-keyword">new</span> RouteBuilder() {
        <span class="code-keyword">public</span> void configure() <span class="code-keyword">throws</span> Exception {
            <span class="code-comment">// We pool the atom feeds from the source <span class="code-keyword">for</span> further processing in the seda queue
</span>            <span class="code-comment">// we set the delay to 1 second <span class="code-keyword">for</span> each pool as <span class="code-keyword">this</span> is a unit test also and we can
</span>            <span class="code-comment">// not wait the <span class="code-keyword">default</span> poll interval of 60 seconds.
</span>            <span class="code-comment">// Using splitEntries=<span class="code-keyword">true</span> will during polling only fetch one Atom Entry at any given time.
</span>            <span class="code-comment">// As the feed.atom file contains 7 entries, using <span class="code-keyword">this</span> will require 7 polls to fetch the entire
</span>            <span class="code-comment">// content. When Camel have reach the end of entries it will refresh the atom feed from URI source
</span>            <span class="code-comment">// and restart - but as Camel by <span class="code-keyword">default</span> uses the UpdatedDateFilter it will only deliver <span class="code-keyword">new</span>
</span>            <span class="code-comment">// blog entries to <span class="code-quote">"seda:feeds"</span>. So only when James Straham updates his blog with a <span class="code-keyword">new</span> entry
</span>            <span class="code-comment">// Camel will create an exchange <span class="code-keyword">for</span> the seda:feeds.
</span>            from(<span class="code-quote">"atom:file:src/test/data/feed.atom?splitEntries=<span class="code-keyword">true</span>&amp;consumer.delay=1000"</span>).to(<span class="code-quote">"seda:feeds"</span>);

            <span class="code-comment">// From the feeds we filter each blot entry by using our blog service class
</span>            from(<span class="code-quote">"seda:feeds"</span>).filter().method(<span class="code-quote">"blogService"</span>, <span class="code-quote">"goodBlog"</span>).to(<span class="code-quote">"seda:goodBlogs"</span>);

            <span class="code-comment">// And the good blogs is moved to a mock queue as <span class="code-keyword">this</span> sample is also used <span class="code-keyword">for</span> unit testing
</span>            <span class="code-comment">// <span class="code-keyword">this</span> is one of the strengths in Camel that you can also use the mock endpoint <span class="code-keyword">for</span> your
</span>            <span class="code-comment">// unit tests
</span>            from(<span class="code-quote">"seda:goodBlogs"</span>).to(<span class="code-quote">"mock:result"</span>);
        }
    };
}

/**
 * This is the actual junit test method that does the assertion that our routes is working
 * as expected
 */
<span class="code-keyword">public</span> void testFiltering() <span class="code-keyword">throws</span> Exception {
    <span class="code-comment">// Get the mock endpoint
</span>    MockEndpoint mock = context.getEndpoint(<span class="code-quote">"mock:result"</span>, MockEndpoint.class);

    <span class="code-comment">// There should be two good blog entries from the feed
</span>    mock.expectedMessageCount(2);

    <span class="code-comment">// Asserts that the above expectations is <span class="code-keyword">true</span>, will <span class="code-keyword">throw</span> assertions exception <span class="code-keyword">if</span> it failed
</span>    <span class="code-comment">// Camel will <span class="code-keyword">default</span> wait max 20 seconds <span class="code-keyword">for</span> the assertions to be <span class="code-keyword">true</span>, <span class="code-keyword">if</span> the conditions
</span>    <span class="code-comment">// is <span class="code-keyword">true</span> sooner Camel will <span class="code-keyword">continue</span>
</span>    mock.assertIsSatisfied();
}

/**
 * Services <span class="code-keyword">for</span> blogs
 */
<span class="code-keyword">public</span> class BlogService {

    /**
     * Tests the blogs <span class="code-keyword">if</span> its a good blog entry or not
     */
    <span class="code-keyword">public</span> <span class="code-object">boolean</span> isGoodBlog(Exchange exchange) {
        Entry entry = exchange.getIn().getBody(Entry.class);
        <span class="code-object">String</span> title = entry.getTitle();

        <span class="code-comment">// We like blogs about Camel
</span>        <span class="code-object">boolean</span> good = title.toLowerCase().contains(<span class="code-quote">"camel"</span>);
        <span class="code-keyword">return</span> good;
    }

}</pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-BeanComponent"></a>Bean Component</h2>

<p>The <b>bean:</b> component binds beans to Camel message exchanges.</p>


<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">bean:someName[?methodName=someMethod]</pre>
</div></div>

<p>Where <b>someName</b> can be any string which is used to lookup the bean in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a> and <b>someMethod</b> defines the name of the method to invoke.</p>

<p>This will use the <a href="/confluence/display/CAMEL/Bean+Binding" title="Bean Binding">Bean Binding</a> to map the message exchange to the bean.</p>

<h3><a name="BookComponentAppendix-Using"></a>Using</h3>

<p>The object instance that is used to consume messages must be explicitly registered with the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>. For example if you are using Spring you must define the bean in the spring.xml; or if you don't use Spring then put the bean in JNDI.</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-comment">// lets populate the context with the services we need
</span><span class="code-comment">// note that we could just use a spring.xml file to avoid <span class="code-keyword">this</span> step
</span>JndiContext context = <span class="code-keyword">new</span> JndiContext();
context.bind(<span class="code-quote">"bye"</span>, <span class="code-keyword">new</span> SayService(<span class="code-quote">"Good Bye!"</span>));

CamelContext camelContext = <span class="code-keyword">new</span> DefaultCamelContext(context);</pre>
</div></div>

<p>Once an endpoint has been registered, you can build Camel routes that use it to process exchanges.</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-comment">// lets add simple route
</span>camelContext.addRoutes(<span class="code-keyword">new</span> RouteBuilder() {
    <span class="code-keyword">public</span> void configure() {
        from(<span class="code-quote">"direct:hello"</span>).to(<span class="code-quote">"pojo:bye"</span>);
    }
});</pre>
</div></div>

<p>A <b>bean:</b> endpoint cannot be defined as the input to the route; i.e. you cannot consume from it, you can only route from some inbound message <a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a> to the bean endpoint as output.  So consider using a <b>direct:</b> or <b>queue:</b> endpoint as the input.  </p>

<p>You can use the createProxy() methods on <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/bean/ProxyHelper.html" title="Visit page outside Confluence" rel="nofollow">ProxyHelper<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> to create a proxy that will generate BeanExchanges and send them to any endpoint:</p>

<div class="code"><div class="codeContent">
<pre class="code-java">Endpoint endpoint = camelContext.getEndpoint(<span class="code-quote">"direct:hello"</span>);
ISay proxy = ProxyHelper.createProxy(endpoint, ISay.class);
<span class="code-object">String</span> rc = proxy.say();
assertEquals(<span class="code-quote">"Good Bye!"</span>, rc);</pre>
</div></div>

<h3><a name="BookComponentAppendix-Beanbinding"></a>Bean binding</h3>

<p>The binding of a Camel <a href="/confluence/display/CAMEL/Message" title="Message">Message</a> to a bean method call can occur in different ways</p>

<ul>
	<li>if the bean can be converted to a <a href="/confluence/display/CAMEL/Processor" title="Processor">Processor</a> using the <a href="/confluence/display/CAMEL/Type+Converter" title="Type Converter">Type Converter</a> mechanism then this is used to process the message. This mechanism is used by the <a href="/confluence/display/CAMEL/ActiveMQ" title="ActiveMQ">ActiveMQ</a> component to allow any MessageListener to be invoked by the <a href="/confluence/display/CAMEL/Bean" title="Bean">Bean</a> component</li>
	<li>if the body of the message can be converted to a <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/bean/BeanInvocation.html" title="Visit page outside Confluence" rel="nofollow">BeanInvocation<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> (the default payload used by the <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/bean/ProxyHelper.html" title="Visit page outside Confluence" rel="nofollow">ProxyHelper<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>) - then that its used to invoke the method and pass the arguments</li>
	<li>if the message contains the header <b>org.apache.camel.MethodName</b> then that method is invoked, converting the body to whatever the argument is to the method</li>
	<li>otherwise the type of the method body is used to try find a method which matches; an error is thrown if a single method cannot be chosen unambiguously.</li>
	<li>you can also use Exchange as the parameter itself, but then the return type must be void.</li>
</ul>


<p>By default the return value is set on the outbound message body.</p>

<p>For example a POJO such as:</p>
<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">public</span> class Bar {

    <span class="code-keyword">public</span> <span class="code-object">String</span> doSomething(<span class="code-object">String</span> body) {
      <span class="code-comment">// process the in body and <span class="code-keyword">return</span> whatever you want
</span>      <span class="code-keyword">return</span> <span class="code-quote">"Bye World"</span>;
   }</pre>
</div></div>

<p>Or the Exchange example. Notice that the return type must be <b>void</b>:</p>
<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">public</span> class Bar {

    <span class="code-keyword">public</span> void doSomething(Exchange exchange) {
      <span class="code-comment">// process the exchange
</span>      exchange.getIn().setBody(<span class="code-quote">"Bye World"</span>);
   }</pre>
</div></div>

<p>For example you could write a method like this (showing also a feature in Camel, the @MessageDrive annotation):</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">public</span> class Foo {

    @MessageDriven(uri = <span class="code-quote">"activemq:my.queue"</span>)
    <span class="code-keyword">public</span> void doSomething(<span class="code-object">String</span> body) {
		<span class="code-comment">// process the inbound message here
</span>    }

}</pre>
</div></div>

<p>Here Camel with subscribe to an ActiveMQ queue, then convert the message payload to a String (so dealing with TextMessage, ObjectMessage and BytesMessage in JMS), then process this method.</p>

<h3><a name="BookComponentAppendix-UsingAnnotationstobindparameterstotheExchange"></a>Using Annotations to bind parameters to the Exchange</h3>

<p>The annotations can be used to bind in situations where traditional methods would result in ambiguous methods. So by adding annotations you can decorate your bean to help Camel invoke the correct method.</p>

<p>You can also use the following annotations to bind parameters to different kinds of <a href="/confluence/display/CAMEL/Expression" title="Expression">Expression</a></p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Annotation </th>
<th class='confluenceTh'> Meaning </th>
</tr>
<tr>
<td class='confluenceTd'> <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/Body.html" title="Visit page outside Confluence" rel="nofollow">@Body<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> To bind to an inbound message body </td>
</tr>
<tr>
<td class='confluenceTd'> <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/Header.html" title="Visit page outside Confluence" rel="nofollow">@Header<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> To bind to an inbound message header </td>
</tr>
<tr>
<td class='confluenceTd'> <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/Headers.html" title="Visit page outside Confluence" rel="nofollow">@Headers<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> To bind to the Map of the inbound message headers </td>
</tr>
<tr>
<td class='confluenceTd'> <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/OutHeader.html" title="Visit page outside Confluence" rel="nofollow">@OutHeader<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> To bind to an outbound message header </td>
</tr>
<tr>
<td class='confluenceTd'> <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/OutHeaders.html" title="Visit page outside Confluence" rel="nofollow">@OutHeaders<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> To bind to the Map of the outbound message headers </td>
</tr>
<tr>
<td class='confluenceTd'> <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/Property.html" title="Visit page outside Confluence" rel="nofollow">@Property<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> To bind to a named property on the exchange </td>
</tr>
<tr>
<td class='confluenceTd'> <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/Properties.html" title="Visit page outside Confluence" rel="nofollow">@Properties<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> To bind to the property map on the exchange </td>
</tr>
</tbody></table>

<p>For example</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">public</span> class Foo {
	
    @MessageDriven(uri = <span class="code-quote">"activemq:my.queue"</span>)
    <span class="code-keyword">public</span> void doSomething(@Header('JMSCorrelationID') <span class="code-object">String</span> correlationID, @Body <span class="code-object">String</span> body) {
		<span class="code-comment">// process the inbound message here
</span>    }

}</pre>
</div></div>

<p>In the above you can now pass the Message.getJMSCorrelationID() as a parameter to the method (using the <a href="/confluence/display/CAMEL/Type+Converter" title="Type Converter">Type Converter</a> to adapt the value to the type of the parameter).</p>

<p>Finally you don't need the @MessageDriven annotation; as the Camel route could describe which method to invoke.</p>

<p>e.g. a route could look like</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"activemq:someQueue"</span>).
  to(<span class="code-quote">"bean:myBean"</span>);</pre>
</div></div>

<p>Here <b>myBean</b> would be looked up in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a> (such as JNDI or the Spring ApplicationContext), then the body of the message would be used to try figure out what method to call.</p>

<p>If you want to be explicit you can use</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"activemq:someQueue"</span>).
  to(<span class="code-quote">"bean:myBean?methodName=doSomething"</span>);</pre>
</div></div>

<p>And here we have a nifty example for you to show some great power in Camel. You can mix and match the annotations with the normal parameters, so we can have this example with annotations and the Exchange also:</p>
<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">public</span> void doSomething(@Header(name = <span class="code-quote">"user"</span>) <span class="code-object">String</span> user, @Body <span class="code-object">String</span> body, Exchange exchange) {
        exchange.getIn().setBody(body + <span class="code-quote">"MyBean"</span>);
    }</pre>
</div></div>

<h3><a name="BookComponentAppendix-UsingExpressionLanguages"></a>Using Expression Languages</h3>

<p>You can also use any of the <a href="/confluence/display/CAMEL/Languages" title="Languages">Languages</a> supported in Camel to bind expressions to method parameters when using bean integration. For example you can use any of these annotations...</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Annotation</th>
<th class='confluenceTh'>Description</th>
</tr>
<tr>
<td class='confluenceTd'><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-script/apidocs/org/apache/camel/builder/script/BeanShell.html" title="Visit page outside Confluence" rel="nofollow">@BeanShell<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> Inject a <a href="/confluence/display/CAMEL/BeanShell" title="BeanShell">BeanShell</a> expression </td>
</tr>
<tr>
<td class='confluenceTd'><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-juel/apidocs/org/apache/camel/language/juel/EL.html" title="Visit page outside Confluence" rel="nofollow">@EL<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> Inject an <a href="/confluence/display/CAMEL/EL" title="EL">EL</a> expression </td>
</tr>
<tr>
<td class='confluenceTd'><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-script/apidocs/org/apache/camel/builder/script/Groovy.html" title="Visit page outside Confluence" rel="nofollow">@Groovy<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> Inject a <a href="/confluence/display/CAMEL/Groovy" title="Groovy">Groovy</a> expression </td>
</tr>
<tr>
<td class='confluenceTd'><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-script/apidocs/org/apache/camel/builder/script/JavaScript.html" title="Visit page outside Confluence" rel="nofollow">@JavaScript<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> Inject a <a href="/confluence/display/CAMEL/JavaScript" title="JavaScript">JavaScript</a> expression </td>
</tr>
<tr>
<td class='confluenceTd'><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-ognl/apidocs/org/apache/camel/language/ognl/OGNL.html" title="Visit page outside Confluence" rel="nofollow">@OGNL<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> Inject an <a href="/confluence/display/CAMEL/OGNL" title="OGNL">OGNL</a> expression </td>
</tr>
<tr>
<td class='confluenceTd'><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-script/apidocs/org/apache/camel/builder/script/PHP.html" title="Visit page outside Confluence" rel="nofollow">@PHP<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> Inject a <a href="/confluence/display/CAMEL/PHP" title="PHP">PHP</a> expression </td>
</tr>
<tr>
<td class='confluenceTd'><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-script/apidocs/org/apache/camel/builder/script/Python.html" title="Visit page outside Confluence" rel="nofollow">@Python<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> Inject a <a href="/confluence/display/CAMEL/Python" title="Python">Python</a> expression </td>
</tr>
<tr>
<td class='confluenceTd'><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-script/apidocs/org/apache/camel/builder/script/Ruby.html" title="Visit page outside Confluence" rel="nofollow">@Ruby<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> Inject a <a href="/confluence/display/CAMEL/Ruby" title="Ruby">Ruby</a> expression </td>
</tr>
<tr>
<td class='confluenceTd'><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/language/Simple.html" title="Visit page outside Confluence" rel="nofollow">@Simple<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> Inject an <a href="/confluence/display/CAMEL/Simple" title="Simple">Simple</a> expression </td>
</tr>
<tr>
<td class='confluenceTd'><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/language/XPath.html" title="Visit page outside Confluence" rel="nofollow">@XPath<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> Inject an <a href="/confluence/display/CAMEL/XPath" title="XPath">XPath</a> expression </td>
</tr>
<tr>
<td class='confluenceTd'><span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-saxon/apidocs/org/apache/camel/component/xquery/XQuery.html" title="Visit page outside Confluence" rel="nofollow">@XQuery<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> Inject an <a href="/confluence/display/CAMEL/XQuery" title="XQuery">XQuery</a> expression </td>
</tr>
</tbody></table>

<p>For example</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">public</span> class Foo {
	
    @MessageDriven(uri = <span class="code-quote">"activemq:my.queue"</span>)
    <span class="code-keyword">public</span> void doSomething(@Path(<span class="code-quote">"/foo/bar/text()"</span>) <span class="code-object">String</span> correlationID, @Body <span class="code-object">String</span> body) {
		<span class="code-comment">// process the inbound message here
</span>    }
}</pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-CXFComponent"></a>CXF Component</h2>

<p>The <b>cxf:</b> component provides integration with <span class="nobr"><a href="http://incubator.apache.org/cxf/" title="Visit page outside Confluence" rel="nofollow">Apache CXF<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> for connecting to JAX-WS services hosted in CXF.</p>

<p>Maven users will need to add the following dependency to their pom.xml for this component:</p>

<div class="code"><div class="codeContent">
<pre class="code-java">&lt;dependency&gt;
   &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
   &lt;artifactId&gt;camel-cxf&lt;/artifactId&gt;
   &lt;version&gt;x.x.x&lt;/version&gt;  &lt;!-- use the same version as your Camel core version --&gt;
&lt;/dependency&gt;</pre>
</div></div>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">cxf:<span class="code-comment">//address?options</span></pre>
</div></div>
<p>Where <b>address</b> represents the CXF endpoint's address</p>
<div class="code"><div class="codeContent">
<pre class="code-java">cxf:bean:cxfEndpoint</pre>
</div></div>
<p>Where <b>cxfEndpoint</b> represents the spring bean's name which presents the CXF endpoint</p>

<p>For either style above, you can append options to the URI as follows:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">cxf:bean:cxfEndpoint?wsdlURL=wsdl/hello_world.wsdl&amp;dataFormat=PAYLOAD</pre>
</div></div>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Example </th>
<th class='confluenceTh'> Required? </th>
<th class='confluenceTh'> default value </th>
</tr>
<tr>
<td class='confluenceTd'> wsdlURL </td>
<td class='confluenceTd'> The location of the WSDL. </td>
<td class='confluenceTd'> <span class="nobr"><a href="file://local/wsdl/hello.wsdl" title="Visit page outside Confluence" rel="nofollow">file://local/wsdl/hello.wsdl<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> or wsdl/hello.wsdl </td>
<td class='confluenceTd'> No </td>
<td class='confluenceTd'> WSDL is obtained from endpoint address by default </td>
</tr>
<tr>
<td class='confluenceTd'> serviceClass </td>
<td class='confluenceTd'> The name of the SEI(Service Endpoint Interface) implementation class.  This class can have but does not require JSR181 annotations. </td>
<td class='confluenceTd'> org.apache.camel.Hello </td>
<td class='confluenceTd'> Yes for CXF provider, for CXF Consumer only if POJO dataFormat option is used </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> serviceName </td>
<td class='confluenceTd'> The service name this service is implementing, it maps to the wsdl:service@name. </td>
<td class='confluenceTd'> {<span class="nobr"><a href="http://org.apache.camel" title="Visit page outside Confluence" rel="nofollow">http://org.apache.camel<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>}<br/>
ServiceName </td>
<td class='confluenceTd'> Only if more than one serviceName in WSDL present </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> portName </td>
<td class='confluenceTd'> The port name this service is implementing, it maps to the wsdl:port@name. </td>
<td class='confluenceTd'> {<span class="nobr"><a href="http://org.apache.camel" title="Visit page outside Confluence" rel="nofollow">http://org.apache.camel<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>}<br/>
PortName </td>
<td class='confluenceTd'> Only if more than one portName under the serviceName is present </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> dataFormat </td>
<td class='confluenceTd'> Which data type messages the CXF endpoint supports </td>
<td class='confluenceTd'> POJO, PAYLOAD, MESSAGE </td>
<td class='confluenceTd'> No </td>
<td class='confluenceTd'> POJO </td>
</tr>
<tr>
<td class='confluenceTd'> wrapped </td>
<td class='confluenceTd'> Which kind of operation that CXF  endpoint producer will invoke </td>
<td class='confluenceTd'> true, false </td>
<td class='confluenceTd'> No </td>
<td class='confluenceTd'> false </td>
</tr>
<tr>
<td class='confluenceTd'> setDefaultBus </td>
<td class='confluenceTd'> Will set the default bus when CXF endpoint create a bus by itself </td>
<td class='confluenceTd'> true, false </td>
<td class='confluenceTd'> No </td>
<td class='confluenceTd'> false </td>
</tr>
</tbody></table>

<p>The serviceName and portName are <span class="nobr"><a href="http://en.wikipedia.org/wiki/QName" title="Visit page outside Confluence" rel="nofollow">QNames<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>, so if you provide them be sure to prefix them with their {namespace} as shown in the examples above.</p>

<h4><a name="BookComponentAppendix-Thedescriptionsofthedataformats"></a>The descriptions of the dataformats</h4>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> DataFormat </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> POJO </td>
<td class='confluenceTd'> POJOs (Plain old Java objects) are the Java parameters to the method being invoked on the target server. </td>
</tr>
<tr>
<td class='confluenceTd'> PAYLOAD </td>
<td class='confluenceTd'> PAYLOAD is the message payload (the contents of the soap:body) after message configuration in the CXF endpoint is applied. </td>
</tr>
<tr>
<td class='confluenceTd'> MESSAGE </td>
<td class='confluenceTd'> MESSAGE is the raw message that is received from the transport layer. </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-ConfiguretheCXFendpointswithspring"></a>Configure the CXF endpoints with spring</h3>
<p>You can configure the CXF endpoint with the below spring configuration file, and you can also embed the endpoint into the camelContext tags.</p>
<div class="code"><div class="codeContent">
<pre class="code-java">&lt;beans xmlns=<span class="code-quote">"http:<span class="code-comment">//www.springframework.org/schema/beans"</span>
</span>       xmlns:xsi=<span class="code-quote">"http:<span class="code-comment">//www.w3.org/2001/XMLSchema-instance"</span>
</span>       xmlns:cxf=<span class="code-quote">"http:<span class="code-comment">//activemq.apache.org/camel/schema/cxfEndpoint"</span>
</span>          
       xsi:schemaLocation="
       http:<span class="code-comment">//www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
</span>       http:<span class="code-comment">//activemq.apache.org/camel/schema/cxfEndpoint http://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd
</span>       http:<span class="code-comment">//activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
</span>    "&gt;

   &lt;cxf:cxfEndpoint id=<span class="code-quote">"routerEndpoint"</span> address=<span class="code-quote">"http:<span class="code-comment">//localhost:9003/CamelContext/RouterPort"</span> 
</span>    		serviceClass=<span class="code-quote">"org.apache.hello_world_soap_http.GreeterImpl"</span>/&gt;
    		
   &lt;cxf:cxfEndpoint id=<span class="code-quote">"serviceEndpoint"</span> address=<span class="code-quote">"http:<span class="code-comment">//localhost:9000/SoapContext/SoapPort"</span> 
</span>    		wsdlURL=<span class="code-quote">"testutils/hello_world.wsdl"</span>
    		serviceClass=<span class="code-quote">"org.apache.hello_world_soap_http.Greeter"</span>
    		endpointName=<span class="code-quote">"s:SoapPort"</span>
    		serviceName=<span class="code-quote">"s:SOAPService"</span>
    	xmlns:s=<span class="code-quote">"http:<span class="code-comment">//apache.org/hello_world_soap_http"</span> /&gt;
</span>    		
   &lt;camelContext id=<span class="code-quote">"camel"</span> xmlns=<span class="code-quote">"http:<span class="code-comment">//activemq.apache.org/camel/schema/spring"</span>&gt;
</span>    &lt;route&gt;
      &lt;from uri=<span class="code-quote">"cxf:bean:routerEndpoint"</span> /&gt;
      &lt;to uri=<span class="code-quote">"cxf:bean:serviceEndpoint"</span> /&gt; 
    &lt;/route&gt;
   &lt;/camelContext&gt; 
 

&lt;/beans&gt;</pre>
</div></div>
<p>Be sure to include the JAX-WS <tt>schemaLocation</tt> attribute specified on the root beans element. This allows CXF to validate the file and is required.  Also note the namespace declarations at the end of the &lt;cxf:cxfEndpoint/&gt; tag--these are required because the combined "{namespace}localName" syntax is presently not supported for this tag's attribute values.</p>

<p>The <tt>cxf:cxfEndpoint</tt> element supports many additional attributes:</p>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Value </th>
</tr>
<tr>
<td class='confluenceTd'> PortName </td>
<td class='confluenceTd'> The endpoint name this service is implementing, it maps to the wsdl:port@name. In the format of "ns:PORT_NAME" where ns is a namespace prefix valid at this scope. </td>
</tr>
<tr>
<td class='confluenceTd'> serviceName </td>
<td class='confluenceTd'> The service name this service is implementing, it maps to the wsdl:service@name. In the format of "ns:SERVICE_NAME" where ns is a namespace prefix valid at this scope. </td>
</tr>
<tr>
<td class='confluenceTd'> wsdlURL </td>
<td class='confluenceTd'> The location of the WSDL. Can be on the classpath, file system, or be hosted remotely. </td>
</tr>
<tr>
<td class='confluenceTd'> bindingId </td>
<td class='confluenceTd'> The bindingId for the service model to use </td>
</tr>
<tr>
<td class='confluenceTd'> address </td>
<td class='confluenceTd'> The service publish address </td>
</tr>
<tr>
<td class='confluenceTd'> bus </td>
<td class='confluenceTd'> The bus name that will be used in the jaxws endpoint. </td>
</tr>
<tr>
<td class='confluenceTd'> serviceClass </td>
<td class='confluenceTd'> The class name of the SEI(Service Endpoint Interface) class which could have JSR181 annotation or not  </td>
</tr>
</tbody></table>
<p>It also supports many child elements:</p>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Value </th>
</tr>
<tr>
<td class='confluenceTd'> cxf:inInterceptors </td>
<td class='confluenceTd'> The incoming interceptors for this endpoint. A list of &lt;bean&gt;s or &lt;ref&gt;s. </td>
</tr>
<tr>
<td class='confluenceTd'> cxf:inFaultInterceptors </td>
<td class='confluenceTd'> The incoming fault interceptors for this endpoint.  A list of &lt;bean&gt;s or &lt;ref&gt;s. </td>
</tr>
<tr>
<td class='confluenceTd'> cxf:outInterceptors </td>
<td class='confluenceTd'> The outgoing interceptors for this endpoint. A list of &lt;bean&gt;s or &lt;ref&gt;s. </td>
</tr>
<tr>
<td class='confluenceTd'> cxf:outFaultInterceptors </td>
<td class='confluenceTd'> The outgoing fault interceptors for this endpoint. A list of &lt;bean&gt;s or &lt;ref&gt;s. </td>
</tr>
<tr>
<td class='confluenceTd'> cxf:properties </td>
<td class='confluenceTd'> A properties map which should be supplied to the JAX-WS endpoint. See below. </td>
</tr>
<tr>
<td class='confluenceTd'> cxf:dataBinding </td>
<td class='confluenceTd'> You can specify the which DataBinding will be use in the endpoint, This can be supplied using the Spring &lt;bean class="MyDataBinding"/&gt; syntax. </td>
</tr>
<tr>
<td class='confluenceTd'> cxf:binding </td>
<td class='confluenceTd'> You can specify the BindingFactory for this endpoint to use.  This can be supplied using the Spring &lt;bean class="MyBindingFactory"/&gt; syntax. </td>
</tr>
<tr>
<td class='confluenceTd'> cxf:features </td>
<td class='confluenceTd'> The features that hold the interceptors for this endpoint. A list of &lt;bean&gt;s or &lt;ref&gt;s </td>
</tr>
<tr>
<td class='confluenceTd'> cxf:schemaLocations </td>
<td class='confluenceTd'> The schema locations for endpoint to use. A list of &lt;schemaLocation&gt;s </td>
</tr>
<tr>
<td class='confluenceTd'> cxf:serviceFactory </td>
<td class='confluenceTd'> The service factory for this endpoint to use. This can be supplied using the Spring &lt;bean class="MyServiceFactory"/&gt; syntax </td>
</tr>
</tbody></table>

<p>You can find more advanced examples which show how to provide interceptors and properties here:<br/>
<span class="nobr"><a href="http://cwiki.apache.org/CXF20DOC/jax-ws-configuration.html" title="Visit page outside Confluence" rel="nofollow">http://cwiki.apache.org/CXF20DOC/jax-ws-configuration.html<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></p>

<p><b>NOTE</b><br/>
You can use cxf:properties to set the camel-cxf endpoint's dataFormat and setDefaultBus properties from spring configuration file.</p>
<div class="code"><div class="codeContent">
<pre class="code-xml">&lt;cxf:cxfEndpoint id=<span class="code-quote">"testEndpoint"</span> address=<span class="code-quote">"http://localhost:9000/router"</span>
    serviceClass=<span class="code-quote">"org.apache.camel.component.cxf.HelloService"</span>
    endpointName=<span class="code-quote">"s:PortName"</span>
    serviceName=<span class="code-quote">"s:ServiceName"</span>
    <span class="code-keyword">xmlns:s</span>=<span class="code-quote">"http://www.example.com/test"</span>&gt;
    <span class="code-tag">&lt;cxf:properties&gt;</span>
      <span class="code-tag">&lt;entry key=<span class="code-quote">"dataFormat"</span> value=<span class="code-quote">"MESSAGE"</span>/&gt;</span>
      <span class="code-tag">&lt;entry key=<span class="code-quote">"setDefaultBus"</span> value=<span class="code-quote">"true"</span>/&gt;</span>
    <span class="code-tag">&lt;/cxf:properties&gt;</span>
  <span class="code-tag">&lt;/cxf:cxfEndpoint&gt;</span></pre>
</div></div>


<h3><a name="BookComponentAppendix-Howtoletcamelcxfcomponenttouselog4jinsteadofjava.util.logging"></a>How to let camel-cxf component to use log4j instead of java.util.logging</h3>
<p>CXF's default logger is using java.util.logging, if you want to change it to log4j.<br/>
Here is the instruction: Create a file, in the classpath, named META-INF/cxf/org.apache.cxf.logger.This file should contain the fully-qualified name of the class (org.apache.cxf.common.logging.Log4jLogger), with no comments, on a single line.</p>

<h3><a name="BookComponentAppendix-HowtoconsumethemessagefromthecamelcxfendpointinPOJOdataformat"></a>How to consume the message from the camel-cxf endpoint in POJO data format</h3>
<p>The camel-cxf endpoint consumer POJO data format is based on the <span class="nobr"><a href="http://cwiki.apache.org/CXF20DOC/invokers.html" title="Visit page outside Confluence" rel="nofollow">cxf invoker<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>, so the message header has a property with the name of CxfConstants.OPERATION_NAME and the message body is a list of the SEI method parameters.</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">public</span> class PersonProcessor <span class="code-keyword">implements</span> Processor {

    <span class="code-keyword">private</span> <span class="code-keyword">static</span> <span class="code-keyword">final</span> <span class="code-keyword">transient</span> Log LOG = LogFactory.getLog(PersonProcessor.class);

    <span class="code-keyword">public</span> void process(Exchange exchange) <span class="code-keyword">throws</span> Exception {
        LOG.info(<span class="code-quote">"processing exchange in camel"</span>);
        <span class="code-comment">// Get the parameters list which element is the holder.
</span>        MessageContentsList msgList = (MessageContentsList)exchange.getIn().getBody();
        Holder&lt;<span class="code-object">String</span>&gt; personId = (Holder&lt;<span class="code-object">String</span>&gt;)msgList.get(0);
        Holder&lt;<span class="code-object">String</span>&gt; ssn = (Holder&lt;<span class="code-object">String</span>&gt;)msgList.get(1);
        Holder&lt;<span class="code-object">String</span>&gt; name = (Holder&lt;<span class="code-object">String</span>&gt;)msgList.get(2);

        <span class="code-keyword">if</span> (personId.value == <span class="code-keyword">null</span> || personId.value.length() == 0) {
            LOG.info(<span class="code-quote">"person id 123, so throwing exception"</span>);
            <span class="code-comment">// Try to <span class="code-keyword">throw</span> out the soap fault message
</span>            org.apache.camel.wsdl_first.types.UnknownPersonFault personFault =
                <span class="code-keyword">new</span> org.apache.camel.wsdl_first.types.UnknownPersonFault();
            personFault.setPersonId("");
            org.apache.camel.wsdl_first.UnknownPersonFault fault =
                <span class="code-keyword">new</span> org.apache.camel.wsdl_first.UnknownPersonFault(<span class="code-quote">"Get the <span class="code-keyword">null</span> value of person name"</span>, personFault);
            <span class="code-comment">// Since camel has its own exception handler framework, we can't <span class="code-keyword">throw</span> the exception to trigger it
</span>            <span class="code-comment">// We just set the fault message in the exchange <span class="code-keyword">for</span> camel-cxf component handling
</span>            exchange.getFault().setBody(fault);
        }

        name.value = <span class="code-quote">"Bonjour"</span>;
        ssn.value = <span class="code-quote">"123"</span>;
        LOG.info(<span class="code-quote">"setting Bonjour as the response"</span>);
        <span class="code-comment">// Set the response message, first element is the <span class="code-keyword">return</span> value of the operation,
</span>        <span class="code-comment">// the others are the holders of method parameters
</span>        exchange.getOut().setBody(<span class="code-keyword">new</span> <span class="code-object">Object</span>[] {<span class="code-keyword">null</span>, personId, ssn, name});
    }

}</pre>
</div></div>


<h3><a name="BookComponentAppendix-HowtopreparethemessageforthecamelcxfendpointinPOJOdataformat"></a>How to prepare the message for the camel-cxf endpoint in POJO data format</h3>
<p>The camel-cxf endpoint producer is based on the <span class="nobr"><a href="https://svn.apache.org/repos/asf/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java" title="Visit page outside Confluence" rel="nofollow">cxf client API<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. First you need to specify the operation name in the message header , then add the method parameters into a list and set the message with this parameter list will be ok. The response message's body is an object array, you can get the result from that array. </p>

<div class="code"><div class="codeContent">
<pre class="code-java">Exchange senderExchange = <span class="code-keyword">new</span> DefaultExchange(context, ExchangePattern.InOut);
<span class="code-keyword">final</span> List&lt;<span class="code-object">String</span>&gt; params = <span class="code-keyword">new</span> ArrayList&lt;<span class="code-object">String</span>&gt;();
<span class="code-comment">// Prepare the request message <span class="code-keyword">for</span> the camel-cxf procedure
</span>params.add(TEST_MESSAGE);
senderExchange.getIn().setBody(params);
senderExchange.getIn().setHeader(CxfConstants.OPERATION_NAME, ECHO_OPERATION);

Exchange exchange = template.send(<span class="code-quote">"direct:EndpointA"</span>, senderExchange);

org.apache.camel.Message out = exchange.getOut();
<span class="code-comment">// The response message's body is an object array which first element is the <span class="code-keyword">return</span> value of the operation,
</span><span class="code-comment">// If there are some holder parameters, the holder parameter will be filled in the reset of array.
</span><span class="code-object">Object</span>[] output = (<span class="code-object">Object</span>[])out.getBody();
LOG.info(<span class="code-quote">"Received output text: "</span> + output[0]);
Map&lt;<span class="code-object">String</span>, <span class="code-object">Object</span>&gt; responseContext = CastUtils.<span class="code-keyword">cast</span>((Map)out.getHeader(Client.RESPONSE_CONTEXT));
assertNotNull(responseContext);
assertEquals(<span class="code-quote">"We should get the response context here"</span>, <span class="code-quote">"UTF-8"</span>, responseContext.get(org.apache.cxf.message.Message.ENCODING));
assertEquals(<span class="code-quote">"Reply body on Camel is wrong"</span>, <span class="code-quote">"echo "</span> + TEST_MESSAGE, output[0]);</pre>
</div></div>


<h3><a name="BookComponentAppendix-Howtopropagatecamelcxfendpoint%27srequestandresponsecontext"></a>How to propagate camel-cxf endpoint's request and response context</h3>
<p><span class="nobr"><a href="https://svn.apache.org/repos/asf/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java" title="Visit page outside Confluence" rel="nofollow">cxf client API<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> provides a way to invoke the operation with request and response context. If you are using camel-cxf endpoint producer to invoke the outside web service, you can set the request context and get response context with below codes.</p>

<div class="code"><div class="codeContent">
<pre class="code-java">CxfExchange exchange = (CxfExchange)template.send(getJaxwsEndpointUri(), <span class="code-keyword">new</span> Processor() {
            <span class="code-keyword">public</span> void process(<span class="code-keyword">final</span> Exchange exchange) {
                <span class="code-keyword">final</span> List&lt;<span class="code-object">String</span>&gt; params = <span class="code-keyword">new</span> ArrayList&lt;<span class="code-object">String</span>&gt;();
                params.add(TEST_MESSAGE);
                <span class="code-comment">// Set the request context to the inMessage
</span>                Map&lt;<span class="code-object">String</span>, <span class="code-object">Object</span>&gt; requestContext = <span class="code-keyword">new</span> HashMap&lt;<span class="code-object">String</span>, <span class="code-object">Object</span>&gt;();
                requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, JAXWS_SERVER_ADDRESS);
                exchange.getIn().setBody(params);
                exchange.getIn().setHeader(Client.REQUEST_CONTEXT , requestContext);
                exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, GREET_ME_OPERATION);
            }
        });
        org.apache.camel.Message out = exchange.getOut();
        <span class="code-comment">// The output is an object array, the fist element of the array is the <span class="code-keyword">return</span> value        
</span>        <span class="code-object">Object</span>[] output = (<span class="code-object">Object</span>[])out.getBody();
        LOG.info(<span class="code-quote">"Received output text: "</span> + output[0]);
        <span class="code-comment">// Get the response context form outMessage
</span>        Map&lt;<span class="code-object">String</span>, <span class="code-object">Object</span>&gt; responseContext = CastUtils.<span class="code-keyword">cast</span>((Map)out.getHeader(Client.RESPONSE_CONTEXT));
        assertNotNull(responseContext);
        assertEquals(<span class="code-quote">"Get the wrong wsdl opertion name"</span>, <span class="code-quote">"{http:<span class="code-comment">//apache.org/hello_world_soap_http}greetMe"</span>, responseContext.get(<span class="code-quote">"javax.xml.ws.wsdl.operation"</span>).toString());</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-DataSetComponent"></a>DataSet Component</h2>

Testing of distributed and asynchronous processing is notoriously difficult. The <a href="/confluence/display/CAMEL/Mock" title="Mock">Mock</a>, <a href="/confluence/display/CAMEL/Test" title="Test">Test</a> and <a href="/confluence/display/CAMEL/DataSet" title="DataSet">DataSet</a> endpoints work great with the <a href="/confluence/display/CAMEL/Spring+Testing" title="Spring Testing">Spring Testing</a> framework to simplify your unit and integration testing using <a href="/confluence/display/CAMEL/Enterprise+Integration+Patterns" title="Enterprise Integration Patterns">Enterprise Integration Patterns</a> and Camel's large range of <a href="/confluence/display/CAMEL/Components" title="Components">Components</a> together with the powerful <a href="/confluence/display/CAMEL/Mock" title="Mock">Mock</a> and <a href="/confluence/display/CAMEL/Test" title="Test">Test</a> testing endpoints.

<p>The DataSet component (available since 1.3.0) provides a mechanism to easily perform load &amp; soak testing of your system. It works by allowing you to create <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/dataset/DataSet.html" title="Visit page outside Confluence" rel="nofollow">DataSet instances<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> both as a source of messages and as a way to assert that the data set is received.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">dataset:name</pre>
</div></div>

<p>Where <b>name</b> is used to find the <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/dataset/DataSet.html" title="Visit page outside Confluence" rel="nofollow">DataSet instance<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a></p>

<h3><a name="BookComponentAppendix-Example"></a>Example</h3>

<p>For example to test that a set of messages are sent to a queue then consumed from a queue without loosing any messages.</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-comment">// send the dataset to a queue
</span>from(<span class="code-quote">"dataset:foo"</span>).to(<span class="code-quote">"activemq:SomeQueue"</span>);

<span class="code-comment">// now lets test that the messages are consumed correctly
</span>from(<span class="code-quote">"activemq:SomeQueue"</span>).to(<span class="code-quote">"dataset:foo"</span>);</pre>
</div></div>

<p>The above would look in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a> to find the <b>foo</b> DataSet instance which is used to create the messages.</p>

<p>Then you create a DataSet implementation, such as using the SimpleDataSet as described below, configuring things like how big the data set is and what the messages look like etc.</p>

<h3><a name="BookComponentAppendix-PropertiesonSimpleDataSet"></a>Properties on SimpleDataSet</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Property</th>
<th class='confluenceTh'>Description</th>
</tr>
<tr>
<td class='confluenceTd'>defaultBody</td>
<td class='confluenceTd'>Specifies the default message body. For SimpleDataSet it is a constant payload; though if you want to create custom payloads per message create your own derivation of DataSetSupport</td>
</tr>
<tr>
<td class='confluenceTd'>reportGroup</td>
<td class='confluenceTd'>Specifies the number of messages to be received before reporting progress. Useful for showing progress of a large load test</td>
</tr>
<tr>
<td class='confluenceTd'>size</td>
<td class='confluenceTd'>Specifies how many messages to send/consume</td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-LoadtestingActiveMQwithCamel"></a>Load testing ActiveMQ with Camel</h3>

<p>There is an example of load testing an ActiveMQ queue using Camel in the <span class="nobr"><a href="http://activemq.apache.org/" title="Visit page outside Confluence" rel="nofollow">ActiveMQ<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> source code repository. The code lives at this location</p>

<ul>
	<li><span class="nobr"><a href="https://svn.apache.org/repos/asf/activemq/trunk/activemq-camel-loadtest/" title="Visit page outside Confluence" rel="nofollow">https://svn.apache.org/repos/asf/activemq/trunk/activemq-camel-loadtest/<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
</ul>


<p>You can grab the code</p>

<div class="code"><div class="codeContent">
<pre class="code-java">svn co https:<span class="code-comment">//svn.apache.org/repos/asf/activemq/trunk/activemq-camel-loadtest/</span></pre>
</div></div>

<p>Then try running the test case</p>
<div class="code"><div class="codeContent">
<pre class="code-java">cd activemq-camel-loadtest
mvn clean install</pre>
</div></div>

<p>To see how the test is defined see the <span class="nobr"><a href="https://svn.apache.org/repos/asf/activemq/trunk/activemq-camel-loadtest/src/test/resources/org/apache/activemq/soaktest/LoadTest-context.xml" title="Visit page outside Confluence" rel="nofollow">Spring XML file<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></p>

<div class="code"><div class="codeContent">
<pre class="code-xml">&lt;beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
       <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
       http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
    "&gt;

  <span class="code-tag">&lt;camelContext xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>

    <span class="code-tag">&lt;route&gt;</span>
      <span class="code-tag">&lt;from uri=<span class="code-quote">"dataset:myDataSet"</span>/&gt;</span>
      <span class="code-tag">&lt;to uri=<span class="code-quote">"activemq:test.queue"</span>/&gt;</span>
    <span class="code-tag">&lt;/route&gt;</span>

    <span class="code-tag">&lt;route&gt;</span>
      <span class="code-tag">&lt;from uri=<span class="code-quote">"activemq:test.queue"</span>/&gt;</span>
      <span class="code-tag">&lt;to uri=<span class="code-quote">"dataset:myDataSet"</span>/&gt;</span>
    <span class="code-tag">&lt;/route&gt;</span>

  <span class="code-tag">&lt;/camelContext&gt;</span>

  <span class="code-tag">&lt;bean id=<span class="code-quote">"myDataSet"</span> class=<span class="code-quote">"org.apache.camel.component.dataset.SimpleDataSet"</span>&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"size"</span> value=<span class="code-quote">"10000"</span>/&gt;</span>
    <span class="code-tag">&lt;property name=<span class="code-quote">"reportCount"</span> value=<span class="code-quote">"100"</span>/&gt;</span>
  <span class="code-tag">&lt;/bean&gt;</span>

  <span class="code-tag"><span class="code-comment">&lt;!-- lets create an embedded broker for this test --&gt;</span></span>
  <span class="code-tag">&lt;broker xmlns=<span class="code-quote">"http://activemq.apache.org/schema/core"</span> dataDirectory=<span class="code-quote">"target/activemq"</span>&gt;</span>

    <span class="code-tag">&lt;transportConnectors&gt;</span>
       <span class="code-tag">&lt;transportConnector uri=<span class="code-quote">"tcp://localhost:61616"</span>/&gt;</span>
    <span class="code-tag">&lt;/transportConnectors&gt;</span>

  <span class="code-tag">&lt;/broker&gt;</span>
<span class="code-tag">&lt;/beans&gt;</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<ul>
	<li><a href="/confluence/display/CAMEL/Spring+Testing" title="Spring Testing">Spring Testing</a></li>
</ul>

<h2><a name="BookComponentAppendix-DirectComponent"></a>Direct Component</h2>

<p>The <b>direct:</b> component provides direct, synchronous invocation of any consumers when a producer sends a message exchange.<br/>
This endpoint can be used connect existing routes or if a client in the same JVM as the Camel router wants to access the routes.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">direct:someName</pre>
</div></div>

<p>Where <b>someName</b> can be any string to uniquely identify the endpoint</p>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> allowMultipleConsumers </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> If set to false, then when a second consumer is started on the endpoint, a IllegalStateException is thrown </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-Esper"></a>Esper</h2>

<p>The Esper component supports the <span class="nobr"><a href="http://esper.codehaus.org" title="Visit page outside Confluence" rel="nofollow">Esper Library<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> for Event Stream Processing. The <b>camel-esper</b> library is provided by the <span class="nobr"><a href="http://code.google.com/p/camel-extra/" title="Visit page outside Confluence" rel="nofollow">Camel Extra<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> project which hosts all *GPL related components for Camel.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">esper:name[?option1=value[&amp;option2=value2]]</pre>
</div></div>

<p>When consuming from an Esper endpoint you must specify a <b>pattern</b> or <b>eql</b> statement to query the event stream.</p>

<p>For example</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"esper:<span class="code-comment">//cheese?pattern=every event=MyEvent(bar=5)"</span>).
</span>	to(<span class="code-quote">"activemq:Foo"</span>);</pre>
</div></div>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> pattern </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> The <span class="nobr"><a href="http://esper.codehaus.org/esper-1.11.0/doc/reference/en/html/event_patterns.html" title="Visit page outside Confluence" rel="nofollow">Esper Pattern expression<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> as a String to filter events </td>
</tr>
<tr>
<td class='confluenceTd'> eql </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> The <span class="nobr"><a href="http://esper.codehaus.org/esper-1.11.0/doc/reference/en/html/eql_clauses.html" title="Visit page outside Confluence" rel="nofollow">Esper EQL expression<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> as a String to filter events </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Demo"></a>Demo</h3>

<p>There is a <span class="nobr"><a href="http://code.google.com/p/camel-extra/wiki/EsperDemo" title="Visit page outside Confluence" rel="nofollow">demo which shows how to work with ActiveMQ, Camel and Esper<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> in the <span class="nobr"><a href="http://code.google.com/p/camel-extra/" title="Visit page outside Confluence" rel="nofollow">Camel Extra<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> project</p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<ul>
	<li><span class="nobr"><a href="http://code.google.com/p/camel-extra/wiki/EsperDemo" title="Visit page outside Confluence" rel="nofollow">Esper Camel Demo<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
</ul>

<h2><a name="BookComponentAppendix-EventComponent"></a>Event Component</h2>

<p>The <b>event:</b> component provides access to the Spring ApplicationEvent objects. This allows you to publish ApplicationEvent objects to a Spring ApplicationContext or to consume them. You can then use <a href="/confluence/display/CAMEL/Enterprise+Integration+Patterns" title="Enterprise Integration Patterns">Enterprise Integration Patterns</a> to process them such as <a href="/confluence/display/CAMEL/Message+Filter" title="Message Filter">Message Filter</a>.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">event:<span class="code-comment">//<span class="code-keyword">default</span></span></pre>
</div></div>


<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-FileComponent"></a>File Component</h2>

<p>The File component provides access to file systems; allowing files to be processed by any other Camel <a href="/confluence/display/CAMEL/Components" title="Components">Components</a> or messages from other components can be saved to disk.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">file:fileOrDirectoryName</pre>
</div></div>

<p>or</p>

<div class="code"><div class="codeContent">
<pre class="code-java">file:<span class="code-comment">//fileOrDirectoryName</span></pre>
</div></div>

<p>Where <b>fileOrDirectoryName</b> represents the underlying file name. Camel will determine if <b>fileOrDirectoryName</b> is a file or directory. </p>

<table cellpadding='5' width='85%' cellspacing='8px' class='infoMacro' border="0" align='center'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b class="strong">Important Information</b><br />
<p>See the section "Common gotchas with folder and filenames" below.</p></td></tr></table>

<h3><a name="BookComponentAppendix-URIOptions"></a>URI Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> initialDelay </td>
<td class='confluenceTd'> 1000 </td>
<td class='confluenceTd'> Camel 1.3 or older: milliseconds before polling the file/directory starts</td>
</tr>
<tr>
<td class='confluenceTd'> delay </td>
<td class='confluenceTd'> 500 </td>
<td class='confluenceTd'> Camel 1.3 or older: milliseconds before the next poll of the file/directory</td>
</tr>
<tr>
<td class='confluenceTd'> useFixedDelay </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Camel 1.3 or older:  <b>true</b> to use fixed delay between pools, otherwise fixed rate is used. See <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html" title="Visit page outside Confluence" rel="nofollow">ScheduledExecutorService<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> in JDK for details.</td>
</tr>
<tr>
<td class='confluenceTd'> consumer.initialDelay </td>
<td class='confluenceTd'> 1000 </td>
<td class='confluenceTd'> Camel 1.4: milliseconds before polling the file/directory starts</td>
</tr>
<tr>
<td class='confluenceTd'> consumer.delay </td>
<td class='confluenceTd'> 500 </td>
<td class='confluenceTd'>Camel 1.4: milliseconds before the next poll of the file/directory</td>
</tr>
<tr>
<td class='confluenceTd'> consumer.useFixedDelay </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Camel 1.4:  <b>true</b> to use fixed delay between pools, otherwise fixed rate is used. See <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html" title="Visit page outside Confluence" rel="nofollow">ScheduledExecutorService<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> in JDK for details.</td>
</tr>
<tr>
<td class='confluenceTd'> recursive </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> if a directory, will look for changes in files in all the sub directories</td>
</tr>
<tr>
<td class='confluenceTd'> lock </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> if true will lock the file for the duration of the processing </td>
</tr>
<tr>
<td class='confluenceTd'> regexPattern </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> will only fire a an exchange for a file that matches the regex pattern</td>
</tr>
<tr>
<td class='confluenceTd'> delete </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> If delete is true then the file will be deleted when it is processed (the default is to move it, see below) </td>
</tr>
<tr>
<td class='confluenceTd'> noop </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> If true then the file is not moved or deleted in any way (see below). This option is good for read only data, or for <a href="/confluence/display/CAMEL/ETL" title="ETL">ETL</a> type requirements </td>
</tr>
<tr>
<td class='confluenceTd'> moveNamePrefix </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The prefix String perpended to the filename when moving it. For example to move processed files into the <em>done</em> directory, set this value to 'done/' </td>
</tr>
<tr>
<td class='confluenceTd'> moveNamePostfix </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The postfix String appended to the filename when moving it. For example to rename processed files from <em>foo</em> to <em>foo.old</em> set this value to '.old' </td>
</tr>
<tr>
<td class='confluenceTd'> append </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> When writing do we append to the end of the file, or replace it? </td>
</tr>
<tr>
<td class='confluenceTd'> autoCreate </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> If set to true Camel will create the directory to the file if the file path does not exists - Uses File#mkdirs()</td>
</tr>
<tr>
<td class='confluenceTd'> bufferSize </td>
<td class='confluenceTd'> 128kb </td>
<td class='confluenceTd'> Write buffer sized in bytes. Camel uses a default of 128 * 1024 bytes. </td>
</tr>
<tr>
<td class='confluenceTd'> ignoreFileNameHeader </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> If this flag is enabled then producers will ignore the 'org.apache.camel.file.name' header and generate a new dynamic filename </td>
</tr>
<tr>
<td class='confluenceTd'> excludedNamePrefixes </td>
<td class='confluenceTd'> "." </td>
<td class='confluenceTd'> Is used to exclude files if filename is starting with any of the given prefixes. The parameter is a String[] </td>
</tr>
<tr>
<td class='confluenceTd'> excludedNamePostfixes </td>
<td class='confluenceTd'> ".camelLock" </td>
<td class='confluenceTd'> Is used to exclude files if filename is ending with any of the given prefixes. The parameter is a String[] </td>
</tr>
<tr>
<td class='confluenceTd'> generateEmptyExchangeWhenIdle </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Option only for the FileConsumer. If this option is <b>true</b> and there was no files to process we simulate processing a single empty file, so an exchange is happening. In this situation the file parameter in FileExchange is null. </td>
</tr>
</tbody></table>

<p>By default the file is locked for the duration of the processing. Also when files are processed they are moved into the <em>.camel</em> directory; so that they appear to be deleted.</p>

<h3><a name="BookComponentAppendix-MessageHeaders"></a>Message Headers</h3>

<p>The following message headers can be used to affect the behavior of the component</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Header </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> org.apache.camel.file.name </td>
<td class='confluenceTd'> Specifies the output file name (relative to the endpoint directory) to be used for the output message when sending to the endpoint. If this is not present then a generated message ID is used as filename instead. </td>
</tr>
<tr>
<td class='confluenceTd'> org.apache.camel.file.name.produced </td>
<td class='confluenceTd'> New in Camel 1.4: The actual absolute filepath (path + name) for the output file that was written. This header is set by Camel and its purpose is providing end-users the name of the file that was written. </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Commongotchaswithfolderandfilenames"></a>Common gotchas with folder and filenames</h3>

<p>When Camel is producing files (writing files) there are a few gotchas how to set a filename of your choice. By default Camel will use the message id as the filename, and since the message id is normally a unique generated id you will end up with filenames such as: ID-MACHINENAME\2443-1211718892437\1-0. Such a filename is not desired and therefore best practice is to provide the filename in the message header "org.apache.camel.file.name".</p>

<p>The sample code below produces files using the message id as the filename:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"direct:report"</span>).to(<span class="code-quote">"file:target/reports"</span>);</pre>
</div></div>
<p>To use report.txt as the filename you have to do:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"direct:report"</span>).setHeader(FileComponent.HEADER_FILE_NAME, <span class="code-quote">"report.txt"</span>).to( <span class="code-quote">"file:target/reports"</span>);</pre>
</div></div>

<p>Canel will default try to auto create the folder if it does not exists, and this is a bad combination with the UUID filename from above. So if you have:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"direct:report"</span>).to(<span class="code-quote">"file:target/reports/report.txt"</span>);</pre>
</div></div>
<p>And you want Camel to store in the file report.txt and autoCreate is true, then Camel will create the folder: target/reports/report.txt/. To fix this set the autoCreate=false and create the folder target/reports manually.</p>
<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"direct:report"</span>).to(<span class="code-quote">"file:target/reports/report.txt?autoCreate=<span class="code-keyword">false</span>"</span>);</pre>
</div></div>
<p>With auto create disabled Camel will store the report in the report.txt as expected.</p>

<h3><a name="BookComponentAppendix-Fileconsumer%2Cscanningfornewfilesgotcha"></a>File consumer, scanning for new files gotcha</h3>

<p>The file consumer scans for new files by keeping an internal modified timestamp of the last consumed file. So if you copy a new file that has an older modified timestamp, then Camel will <b>not</b> pickup this file. This can happen if you are testing and you copy the same file back to the folder that has just been consumed. To remedy this modify the timestamp before copying the file back.</p>

<h3><a name="BookComponentAppendix-Samples"></a>Samples</h3>

<h4><a name="BookComponentAppendix-Readfromadirectoryandwritetoanotherdirectory"></a>Read from a directory and write to another directory</h4>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"file:<span class="code-comment">//inputdir/?delete=<span class="code-keyword">true</span>"</span>).to(<span class="code-quote">"file://outputdir"</span>)</span></pre>
</div></div>

<p>Listen on a directory and create a message for each file dropped there. Copy the contents to the outputdir and delete the file in the inputdir.</p>

<h4><a name="BookComponentAppendix-Readfromadirectoryandprocessthemessageinjava"></a>Read from a directory and process the message in java </h4>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"file:<span class="code-comment">//inputdir/"</span>).process(<span class="code-keyword">new</span> Processor() {
</span>  <span class="code-keyword">public</span> void process(Exchange exchange) <span class="code-keyword">throws</span> Exception {
    <span class="code-object">Object</span> body = exchange.getIn().getBody();
    <span class="code-comment">// <span class="code-keyword">do</span> some business logic with the input body
</span>  }
});</pre>
</div></div>

<p>Body will be File object pointing to the file that was just dropped to the inputdir directory.</p>

<h4><a name="BookComponentAppendix-Readfilesfromadirectoryandsendthecontenttoajmsqueue"></a>Read files from a directory and send the content to a jms queue</h4>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"file:<span class="code-comment">//inputdir/"</span>).convertBodyTo(<span class="code-object">String</span>.class).to(<span class="code-quote">"jms:test.queue"</span>)</span></pre>
</div></div>

<p>By default the file endpoint sends a FileMessage which contains a File as body. If you send this directly to the jms component the jms message will only contain the File object but not the content. By converting the File to a String the message will contain the file contents what is probably what you want to do.</p>

<h4><a name="BookComponentAppendix-Writingtofiles"></a>Writing to files</h4>

<p>Camel is of course also able to write files, eg. producing files. In the sample below we receive some reports on the SEDA queue that we processes before they are written to a directory.</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">public</span> void testToFile() <span class="code-keyword">throws</span> Exception {
    template.sendBody(<span class="code-quote">"seda:reports"</span>, <span class="code-quote">"This is a great report"</span>);

    <span class="code-comment">// give time <span class="code-keyword">for</span> the file to be written before assertions
</span>    <span class="code-object">Thread</span>.sleep(1000);

    <span class="code-comment">// <span class="code-keyword">assert</span> the file exists
</span>    File file = <span class="code-keyword">new</span> File(<span class="code-quote">"target/test-reports/report.txt"</span>);
    assertTrue(<span class="code-quote">"The file should have been written"</span>, file.exists());
}

<span class="code-keyword">protected</span> JndiRegistry createRegistry() <span class="code-keyword">throws</span> Exception {
    <span class="code-comment">// bind our processor in the registry with the given id
</span>    JndiRegistry reg = <span class="code-keyword">super</span>.createRegistry();
    reg.bind(<span class="code-quote">"processReport"</span>, <span class="code-keyword">new</span> ProcessReport());
    <span class="code-keyword">return</span> reg;
}

<span class="code-keyword">protected</span> RouteBuilder createRouteBuilder() <span class="code-keyword">throws</span> Exception {
    <span class="code-keyword">return</span> <span class="code-keyword">new</span> RouteBuilder() {
        <span class="code-keyword">public</span> void configure() <span class="code-keyword">throws</span> Exception {
            <span class="code-comment">// the reports from the seda queue is processed by our processor
</span>            <span class="code-comment">// before they are written to files in the target/reports directory
</span>            from(<span class="code-quote">"seda:reports"</span>).processRef(<span class="code-quote">"processReport"</span>).to(<span class="code-quote">"file:<span class="code-comment">//target/test-reports"</span>);
</span>        }
    };
}

<span class="code-keyword">private</span> class ProcessReport <span class="code-keyword">implements</span> Processor {

    <span class="code-keyword">public</span> void process(Exchange exchange) <span class="code-keyword">throws</span> Exception {
        <span class="code-object">String</span> body = exchange.getIn().getBody(<span class="code-object">String</span>.class);
        <span class="code-comment">// <span class="code-keyword">do</span> some business logic here
</span>
        <span class="code-comment">// set the output to the file
</span>        exchange.getOut().setBody(body);

        <span class="code-comment">// set the output filename using java code logic, notice that <span class="code-keyword">this</span> is done by setting
</span>        <span class="code-comment">// a special header property of the out exchange
</span>        exchange.getOut().setHeader(FileComponent.HEADER_FILE_NAME, <span class="code-quote">"report.txt"</span>);
    }

}</pre>
</div></div>

<h4><a name="BookComponentAppendix-FileProducerfilenamegotchas"></a>FileProducer filename gotchas</h4>

<p>This unit test demonstrates some of the gotchas with filenames for the File Producer.</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">public</span> void testProducerWithMessageIdAsFileName() <span class="code-keyword">throws</span> Exception {
    Endpoint endpoint = context.getEndpoint(<span class="code-quote">"direct:report"</span>);
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody(<span class="code-quote">"This is a good report"</span>);

    FileEndpoint fileEndpoint = resolveMandatoryEndpoint(<span class="code-quote">"file:target/reports/report.txt"</span>, FileEndpoint.class);
    <span class="code-object">String</span> id = fileEndpoint.getGeneratedFileName(exchange.getIn());

    template.send(<span class="code-quote">"direct:report"</span>, exchange);

    File file = <span class="code-keyword">new</span> File(<span class="code-quote">"target/reports/report.txt/"</span> + id);
    assertEquals(<span class="code-quote">"File should exists"</span>, <span class="code-keyword">true</span>, file.exists());
}

<span class="code-keyword">public</span> void testProducerWithConfiguedFileNameInEndpointURI() <span class="code-keyword">throws</span> Exception {
    template.sendBody(<span class="code-quote">"direct:report2"</span>, <span class="code-quote">"This is another good report"</span>);
    File file = <span class="code-keyword">new</span> File(<span class="code-quote">"target/report2.txt"</span>);
    assertEquals(<span class="code-quote">"File should exists"</span>, <span class="code-keyword">true</span>, file.exists());
}

<span class="code-keyword">public</span> void testProducerWithHeaderFileName() <span class="code-keyword">throws</span> Exception {
    template.sendBody(<span class="code-quote">"direct:report3"</span>, <span class="code-quote">"This is <span class="code-keyword">super</span> good report"</span>);
    File file = <span class="code-keyword">new</span> File(<span class="code-quote">"target/report-<span class="code-keyword">super</span>.txt"</span>);
    assertEquals(<span class="code-quote">"File should exists"</span>, <span class="code-keyword">true</span>, file.exists());
}

<span class="code-keyword">protected</span> RouteBuilder createRouteBuilder() <span class="code-keyword">throws</span> Exception {
    <span class="code-keyword">return</span> <span class="code-keyword">new</span> RouteBuilder() {
        <span class="code-keyword">public</span> void configure() <span class="code-keyword">throws</span> Exception {
            from(<span class="code-quote">"direct:report"</span>).to(<span class="code-quote">"file:target/reports/report.txt"</span>);

            from(<span class="code-quote">"direct:report2"</span>).to(<span class="code-quote">"file:target/report2.txt?autoCreate=<span class="code-keyword">false</span>"</span>);

            from(<span class="code-quote">"direct:report3"</span>).setHeader(FileComponent.HEADER_FILE_NAME, <span class="code-quote">"report-<span class="code-keyword">super</span>.txt"</span>).to(<span class="code-quote">"file:target/"</span>);
        }
    };
}</pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-FIX"></a>FIX</h2>

<p>The FIX component supports the <span class="nobr"><a href="http://en.wikipedia.org/wiki/FIX_protocol" title="Visit page outside Confluence" rel="nofollow">FIX protocol<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> by using the <span class="nobr"><a href="http://www.quickfixj.org/" title="Visit page outside Confluence" rel="nofollow">QuickFix/J library<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">fix:<span class="code-comment">//configurationResource</span></pre>
</div></div>

<p>Where <b>configurationResource</b> points to the QuickFix/J configuration file to define how to connect to FIX. This could be a resource on the classpath or refer to a full URL using http: or file: schemes.</p>

<h3><a name="BookComponentAppendix-MessageFormats"></a>Message Formats</h3>

<p>By default this component will attempt to use the <a href="/confluence/display/CAMEL/Type+Converter" title="Type Converter">Type Converter</a> to turn the inbound message body into a <span class="nobr"><a href="http://www.quickfixj.org/quickfixj/javadoc/quickfix/Message.html" title="Visit page outside Confluence" rel="nofollow">QuickFix Message class<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> and all outputs from FIX will be in the same format.</p>

<p>If you are using the <a href="/confluence/display/CAMEL/Artix+Data+Services" title="Artix Data Services">Artix Data Services</a> support then any payload such as files or streams or byte arrays can be converted nicely into FIX messages.</p>

<h3><a name="BookComponentAppendix-Usingcamelfix"></a>Using camel-fix</h3>

<p>To use this module you need to use the <span class="nobr"><a href="http://open.iona.com/products/fuse-mediation-router/" title="Visit page outside Confluence" rel="nofollow">FUSE Mediation Router<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> distribution. Or you could just add the following to your pom.xml, substituting the version number for the latest &amp; greatest release.</p>

<div class="code"><div class="codeContent">
<pre class="code-java">&lt;dependency&gt;
  &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
  &lt;artifactId&gt;camel-parent&lt;/artifactId&gt;
  &lt;version&gt;1.3.0.1-fuse&lt;/version&gt;
&lt;/dependency&gt;</pre>
</div></div>

<p>And ensure you are pointing at the maven repo</p>

<div class="code"><div class="codeContent">
<pre class="code-java">&lt;repository&gt;
     &lt;id&gt;open.iona.m2&lt;/id&gt;
     &lt;name&gt;IONA Open Source Community Release Repository&lt;/name&gt;
     &lt;url&gt;http:<span class="code-comment">//repo.open.iona.com/maven2&lt;/url&gt;
</span>     &lt;snapshots&gt;
       &lt;enabled&gt;<span class="code-keyword">false</span>&lt;/enabled&gt;
     &lt;/snapshots&gt;
     &lt;releases&gt;
       &lt;enabled&gt;<span class="code-keyword">true</span>&lt;/enabled&gt;
     &lt;/releases&gt;
   &lt;/repository&gt;</pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-FTP%2FSFTPComponent"></a>FTP/SFTP Component</h2>

<p>This component provides access to remote file systems over the FTP and SFTP protocols.<br/>
This component is an extension of the <a href="/confluence/display/CAMEL/File" title="File">File</a> component.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">ftp:<span class="code-comment">//[username@]hostname[:port]/filename[?options]
</span>sftp:<span class="code-comment">//[username@]hostname[:port]/filename[?options]</span></pre>
</div></div>

<p>Where <b>filename</b> represents the underlying file name or directory. Can contain nested folders.<br/>
The <b>username</b> is currently only possible to provide in the hostname parameter.<br/>
If no <b>port</b> number is provided. Camel will provide default values according to the protocol. (ftp = 21, sftp = 22)</p>

<h3><a name="BookComponentAppendix-Examples"></a>Examples</h3>
<p><tt><span class="nobr"><a href="ftp://someone@someftpserver.com/public/upload/images/holiday2008?password=secret&amp;binary=true" title="Visit page outside Confluence" rel="nofollow">ftp://someone@someftpserver.com/public/upload/images/holiday2008?password=secret&amp;binary=true<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></tt><br/>
<tt><span class="nobr"><a href="ftp://someoneelse@someotherftpserver.co.uk:12049/reports/2008/budget.txt?password=secret&amp;binary=false&amp;directory=false" title="Visit page outside Confluence" rel="nofollow">ftp://someoneelse@someotherftpserver.co.uk:12049/reports/2008/budget.txt?password=secret&amp;binary=false&amp;directory=false<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></tt><br/>
<tt><span class="nobr"><a href="ftp://publicftpserver.com/download" title="Visit page outside Confluence" rel="nofollow">ftp://publicftpserver.com/download<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></tt></p>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> directory </td>
<td class='confluenceTd'> true</td>
<td class='confluenceTd'> indicates whether or not the given file name should be interpreted by default as a directory or file (as it sometimes hard to be sure with some FTP servers) </td>
</tr>
<tr>
<td class='confluenceTd'> password </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> specifies the password to use to login to the remote file system </td>
</tr>
<tr>
<td class='confluenceTd'> binary </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> specifies the file transfer mode BINARY or ASCII. Default is ASCII. </td>
</tr>
<tr>
<td class='confluenceTd'> setNames </td>
<td class='confluenceTd'> false  </td>
<td class='confluenceTd'> Used by FTPConsumer.  If set to true Camel will set the special filename header FileComponent.HEADER_FILE_NAME value to the filename from the FTP Server.<br/>
<b>Note:</b> In Camel 1.4 the default value has changed to <b>true</b>. </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.delay </td>
<td class='confluenceTd'> 500 </td>
<td class='confluenceTd'> Delay in millis between each poll </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.initialDelay </td>
<td class='confluenceTd'> 1000 </td>
<td class='confluenceTd'> Millis before polling starts </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.userFixedDelay </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> <b>true</b> to use fixed delay between pools, otherwise fixed rate is used. See <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html" title="Visit page outside Confluence" rel="nofollow">ScheduledExecutorService<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> in JDK for details. </td>
</tr>
</tbody></table>

<p>As this component is an extension to the <a href="/confluence/display/CAMEL/File" title="File">File</a> component the options from this parent component is also available.</p>

<h3><a name="BookComponentAppendix-MessageHeaders"></a>Message Headers</h3>

<p>The following message headers is provided in the message. </p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Header </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> file.remote.host </td>
<td class='confluenceTd'> The hostname of the remote server </td>
</tr>
<tr>
<td class='confluenceTd'> file.remote.name </td>
<td class='confluenceTd'> The fullname of the file consumed from the remote server </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Consumerproperties"></a>Consumer properties</h3>

<p>When using FTPConsumer (downloading files from a FTP Server) the consumer specific properties from the <a href="/confluence/display/CAMEL/File" title="File">File</a> component should be prefixed with "consumer.". For example the delay option from File Component should be specified as "consumer.delay=30000" in the URI. See the samples or some of the unit tests of this component.</p>

<h3><a name="BookComponentAppendix-Knownissues"></a>Known issues</h3>

<p>When consuming files (downloading) you must use type conversation to either String or to InputStream for ASCII and BINARY file types. <br/>
In Camel 1.4 this is fixed, as there are build in type converters for the ASCII and BINARY file types, meaning that you do not need the convertBodyTo expression.</p>

<p>Also in Camel 1.3 since setNames is default <b>false</b> then you must explicitly set the filename using the setHeader expression when consuming from FTP directly to File.<br/>
The code below illustrates this:</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">private</span> <span class="code-object">String</span> ftpUrl = <span class="code-quote">"ftp:<span class="code-comment">//camelrider@localhost:21/<span class="code-keyword">public</span>/downloads?password=admin&amp;binary=<span class="code-keyword">false</span>"</span>;
</span><span class="code-keyword">private</span> <span class="code-object">String</span> fileUrl = <span class="code-quote">"file:myfolder/?append=<span class="code-keyword">false</span>&amp;noop=<span class="code-keyword">true</span>"</span>;

<span class="code-keyword">return</span> <span class="code-keyword">new</span> RouteBuilder() {
    <span class="code-keyword">public</span> void configure() <span class="code-keyword">throws</span> Exception {
        from(ftpUrl).setHeader(FileComponent.HEADER_FILE_NAME, constant(<span class="code-quote">"downloaded.txt"</span>)).convertBodyTo(<span class="code-object">String</span>.class).to(fileUrl);
    }
};</pre>
</div></div>

<p>Or you can set the option to <b>true</b> as illustrated below:</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">private</span> <span class="code-object">String</span> ftpUrl = <span class="code-quote">"ftp:<span class="code-comment">//camelrider@localhost:21/<span class="code-keyword">public</span>/downloads?password=admin&amp;binary=<span class="code-keyword">false</span>&amp;setNames=<span class="code-keyword">true</span>"</span>;
</span><span class="code-keyword">private</span> <span class="code-object">String</span> fileUrl = <span class="code-quote">"file:myfolder/?append=<span class="code-keyword">false</span>&amp;noop=<span class="code-keyword">true</span>"</span>;

<span class="code-keyword">return</span> <span class="code-keyword">new</span> RouteBuilder() {
    <span class="code-keyword">public</span> void configure() <span class="code-keyword">throws</span> Exception {
        from(ftpUrl).convertBodyTo(<span class="code-object">String</span>.class).to(fileUrl);
    }
};</pre>
</div></div>

<h3><a name="BookComponentAppendix-Sample"></a>Sample</h3>

<p>In the sample below we setup Camel to download all the reports from the FTP server once every hour (60 min) as BINARY content and store it as files on the local file system.</p>
<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">protected</span> RouteBuilder createRouteBuilder() <span class="code-keyword">throws</span> Exception {
    <span class="code-keyword">return</span> <span class="code-keyword">new</span> RouteBuilder() {
        <span class="code-keyword">public</span> void configure() <span class="code-keyword">throws</span> Exception {
            <span class="code-comment">// we use a delay of 60 minutes (eg. once pr. hour we poll the FTP server
</span>            <span class="code-object">long</span> delay = 60 * 60 * 1000L;

            <span class="code-comment">// from the given FTP server we poll (= download) all the files
</span>            <span class="code-comment">// from the <span class="code-keyword">public</span>/reports folder as BINARY types and store <span class="code-keyword">this</span> as files
</span>            <span class="code-comment">// in a local directory. Camle will use the filenames from the FTPServer
</span>
            <span class="code-comment">// notice that the FTPConsumer properties must be prefixed with <span class="code-quote">"consumer."</span> in the URL
</span>            <span class="code-comment">// the delay parameter is from the FileConsumer component so we should use consumer.delay as
</span>            <span class="code-comment">// the URI parameter name. The FTP Component is an extension of the File Component.
</span>            from(<span class="code-quote">"ftp:<span class="code-comment">//scott@localhost/<span class="code-keyword">public</span>/reports?password=tiger&amp;binary=<span class="code-keyword">true</span>&amp;consumer.delay="</span> + delay).
</span>                to(<span class="code-quote">"file:<span class="code-comment">//target/test-reports"</span>);
</span>        }
    };
}</pre>
</div></div>


<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-HibernateComponent"></a>Hibernate Component</h2>

<p>The <b>hibernate:</b> component allows you to work with databases using Hibernate as the object relational mapping technology to map POJOs to database tables.</p>

<h3><a name="BookComponentAppendix-Sendingtotheendpoint"></a>Sending to the endpoint</h3>

<p>Sending POJOs to the hibernate endpoint inserts entities into the database. The body of the message is assumed to be an entity bean that you have mapped to a relational table using the hibernate .hbm.xml files.</p>

<p>If the body does not contain an entity bean then use a <a href="/confluence/display/CAMEL/Message+Translator" title="Message Translator">Message Translator</a> in front of the endpoint to perform the necessary conversion first.</p>

<h3><a name="BookComponentAppendix-Consumingfromtheendpoint"></a>Consuming from the endpoint</h3>

<p>Consuming messages removes (or updates) entities in the database. This allows you to use a database table as a logical queue, consumers take messages from the queue and then delete/update them to logically remove them from the queue.</p>

<p>If you do not wish to delete the entity when it has been processed you can specify <b>consumeDelete=false</b> on the URI. This will result in the entity being processed each poll.</p>

<p>If you would rather perform some update on the entity to mark it as processed (such as to exclude it from a future query) then you can annotate a method with <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-hibernate/apidocs/org/apache/camel/component/hibernate/Consumed.html" title="Visit page outside Confluence" rel="nofollow">@Consumed<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> which will be invoked on your entity bean when the entity bean is consumed.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">hibernate:[entityClassName]</pre>
</div></div>

<p>For sending to the endpoint, the <b>entityClassName</b> is optional. If specified it is used to help use the <span class="nobr"><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Type+Conversion&amp;linkCreation=true&amp;fromPageId=90525" title="Create Page: Type Conversion" class="createlink">Type Conversion<sup><img class="rendericon" src="/confluence/images/icons/plus.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> to ensure the body is of the correct type.</p>

<p>For consuming the <b>entityClassName</b> is mandatory.</p>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> entityType </td>
<td class='confluenceTd'> entityClassName </td>
<td class='confluenceTd'> Is the provided entityClassName from the URI </td>
</tr>
<tr>
<td class='confluenceTd'> consumeDelete </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Option for HibernateConsumer only. Enables / disables whether or not the entity is deleted after it is consumed. </td>
</tr>
<tr>
<td class='confluenceTd'> consumeLockEntity </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Option for HibernateConsumer only. Enables / disables whether or not to use exclusive locking of each entity while processing the results from the pooling. </td>
</tr>
<tr>
<td class='confluenceTd'> flushOnSend </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Option for HibernateProducer only. Flushes the <span class="nobr"><a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html" title="Visit page outside Confluence" rel="nofollow">EntityManager<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> after the entity beans has been persisted. </td>
</tr>
<tr>
<td class='confluenceTd'> maximumResults </td>
<td class='confluenceTd'> -1 </td>
<td class='confluenceTd'>  Option for HibernateConsumer only. Set the maximum number of results to retrieve on the <span class="nobr"><a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html" title="Visit page outside Confluence" rel="nofollow">Query<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.delay </td>
<td class='confluenceTd'> 500 </td>
<td class='confluenceTd'> Option for HibernateConsumer only. Delay in millis between each poll. </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.initialDelay </td>
<td class='confluenceTd'> 1000 </td>
<td class='confluenceTd'> Option for HibernateConsumer only. Millis before polling starts. </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.userFixedDelay </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Option for HibernateConsumer only. <b>true</b> to use fixed delay between pools, otherwise fixed rate is used. See <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html" title="Visit page outside Confluence" rel="nofollow">ScheduledExecutorService<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> in JDK for details. </td>
</tr>
</tbody></table>


<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-HTTPComponent"></a>HTTP Component</h2>

<p>The <b>http:</b> component provides HTTP based <a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">endpoints</a> for consuming external HTTP resources.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">http:hostname[:port][/resourceUri]</pre>
</div></div>

<h3><a name="BookComponentAppendix-Usage"></a>Usage</h3>

<p>You can only produce to endpoints generated by the HTTP component.  Therefore it should never be used aas input into your camel Routes.  To bind/expose an HTTP endpoint via an http server as input to a camel route, you can use the <a href="/confluence/display/CAMEL/Jetty" title="Jetty">Jetty Component</a></p>

<h3><a name="BookComponentAppendix-HowtosetthePOST%2FPUT%2FINFO%2FDELETE%2FGETtotheHTTPproducer"></a>How to set the POST/PUT/INFO/DELETE/GET to the HTTP producer</h3>

<p>The HTTP component provides a way to set the HTTP request method by setting the message header. Here is an example;</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">new</span> RouteBuilder() {
    <span class="code-keyword">public</span> void configure() {
        from(<span class="code-quote">"direct:start"</span>)
            .setHeader(org.apache.camel.component.http.HttpMethods.HTTP_METHOD, org.apache.camel.component.http.HttpMethods.POST)
	    .to(<span class="code-quote">"http:<span class="code-comment">//www.google.com"</span>)
</span>            .to(<span class="code-quote">"mock:results"</span>);
    }            
};</pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-iBATIS"></a>iBATIS</h2>

<p>The <b>ibatis:</b> component allows you to query, poll, insert, update and delete data in a relational database using <span class="nobr"><a href="http://ibatis.apache.org/" title="Visit page outside Confluence" rel="nofollow">Apache iBATIS<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">ibatis:operationName</pre>
</div></div>

<p>Where <b>operationName</b> is the name in the iBATIS XML configuration file which maps to the query, insert, update or delete operation you wish to evaluate.</p>

<p>For example if you wish to poll a database for rows using iBATIS and then send them to a JMS Queue via <a href="/confluence/display/CAMEL/ActiveMQ" title="ActiveMQ">ActiveMQ</a> you could do</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"ibatis:selectAllAccounts"</span>).
	to(<span class="code-quote">"activemq:MyQueue"</span>);</pre>
</div></div>

<p>Or to consume beans from a JMS queue and insert them into a database you could do...</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"activemq:Some.Queue"</span>).
  to(<span class="code-quote">"ibatis:insertAccount"</span>);</pre>
</div></div>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> initialDelay </td>
<td class='confluenceTd'> 1000 </td>
<td class='confluenceTd'> The number of milliseconds until the first poll when polling (consuming) </td>
</tr>
<tr>
<td class='confluenceTd'> delay </td>
<td class='confluenceTd'> 500 </td>
<td class='confluenceTd'> The number of milliseconds for the subsequent delays after the intial delay </td>
</tr>
<tr>
<td class='confluenceTd'> useFixedDelay </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Whether or not the fixed delay is to be used, to enable a repeated timer </td>
</tr>
</tbody></table>


<p><h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>
|</p>
<h2><a name="BookComponentAppendix-IRCComponent"></a>IRC Component</h2>

<p>The <b>irc:</b> component implements an <span class="nobr"><a href="http://en.wikipedia.org/wiki/Internet_Relay_Chat" title="Visit page outside Confluence" rel="nofollow">IRC<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> (Iternet Relay Chat) transport.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">irc:host[:port]/#room</pre>
</div></div>


<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-JavaSpaceComponent"></a>JavaSpace Component</h2>

<p>The <b>javaspace:</b> component is a transport for working with any JavaSpace compliant implementation, this component has been tested with both the <span class="nobr"><a href="http://www.dancres.org/blitz/" title="Visit page outside Confluence" rel="nofollow">Blitz implementation <sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> and the <span class="nobr"><a href="http://www.gigaspaces.com/" title="Visit page outside Confluence" rel="nofollow">GigaSpace implementation <sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>.<br/>
This component can be used for sending and receiving any object inheriting from the Jini Entry class, it's also possible to pass an id (Spring Bean) of a template that can be used for reading/taking the entries from the space.<br/>
This component can be also used for sending/receiving any serializable object acting as a sort of generic transport. The JavaSpace component contains a special optimization for dealing with the BeanExchange. It can be used, then, for invoking remotely a POJO using as a transport a JavaSpace.<br/>
This latter feature can be used for an easy implementation of the master/worker pattern where a POJO provides the business logic for the worker.<br/>
Look at the test cases for seeing the various usage option for this component.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">javaspace:jini:<span class="code-comment">//host?options</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-Examples"></a>Examples</h3>
<h4><a name="BookComponentAppendix-SendingandReceivingEntries"></a>Sending and Receiving Entries</h4>
<div class="preformatted"><div class="preformattedContent">
<pre>//Sending route
from("direct:input").to("javaspace:jini://localhost?spaceName=mySpace");

//Receiving Route
from("javaspace:jini://localhost?spaceName=mySpace&amp;templateId=template&amp;verb=take&amp;concurrentConsumers=1")
</pre>
</div></div>
<p>In this case the payload can be any object inheriting from the Jini Entry.</p>

<h4><a name="BookComponentAppendix-Sendingandreceivingserializableobjects"></a>Sending and receiving serializable objects</h4>
<p>Using the routes as above it's also possible to send and receive any serializable object. The camel component detects that the payload is not a Jini Entry and then it automatically wraps the payload into a Camel Jini Entry. In this way a JavaSpace can be used as a generic transport.</p>

<h4><a name="BookComponentAppendix-UsingJavaSpaceasaremoteinvocationtransport"></a>Using JavaSpace as a remote invocation transport</h4>
<p>The camel-javaspace component has been tailored to work in combination with the camel-bean component. It's possible, then, to call a remote POJO using JavaSpace as a transport:</p>
<div class="preformatted"><div class="preformattedContent">
<pre>from("direct:input").to("javaspace:jini://localhost?spaceName=mySpace"); //Client side

from("javaspace:jini://localhost?concurrentConsumers=10&amp;spaceName=mySpace").to("pojo:pojo"); //Server side
</pre>
</div></div>
<p>In the code there are two test cases showing how to use the a POJO for realizing the master/worker pattern. The idea is to use the POJO for providing the business logic and relying on camel for sending/receiving requests/replies with the proper correlation.  </p>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> spaceName  </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> This is the JavaSpace name </td>
</tr>
<tr>
<td class='confluenceTd'> verb  </td>
<td class='confluenceTd'> take </td>
<td class='confluenceTd'> This is the verb for getting JavaSpace entries, it can be: take or read </td>
</tr>
<tr>
<td class='confluenceTd'> transactional  </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> if true, sending and receiving of entries is performed under a transaction </td>
</tr>
<tr>
<td class='confluenceTd'> transactionalTimeout  </td>
<td class='confluenceTd'> Long.MAX_VALUE </td>
<td class='confluenceTd'> the transaction timeout  </td>
</tr>
<tr>
<td class='confluenceTd'> concurrentConsumers  </td>
<td class='confluenceTd'> 1 </td>
<td class='confluenceTd'> the number of concurrent consumer getting entries from the JavaSpace </td>
</tr>
<tr>
<td class='confluenceTd'> templateId  </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> if present, this option it's a Spring Bean id to be used as a template for reading/taking entries </td>
</tr>
</tbody></table>


<h3><a name="BookComponentAppendix-Usingcameljavaspace"></a>Using camel-javaspace</h3>

<p>To use this module you need to use the <span class="nobr"><a href="http://open.iona.com/products/fuse-mediation-router/" title="Visit page outside Confluence" rel="nofollow">FUSE Mediation Router<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> distribution. Or you could just add the following to your pom.xml, substituting the version number for the latest &amp; greatest release.</p>

<div class="code"><div class="codeContent">
<pre class="code-java">&lt;dependency&gt;
  &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
  &lt;artifactId&gt;camel-parent&lt;/artifactId&gt;
  &lt;version&gt;1.4.0.0-fuse&lt;/version&gt;
&lt;/dependency&gt;</pre>
</div></div>

<p>And ensure you are pointing at the maven repo</p>

<div class="code"><div class="codeContent">
<pre class="code-java">&lt;repository&gt;
     &lt;id&gt;open.iona.m2&lt;/id&gt;
     &lt;name&gt;IONA Open Source Community Release Repository&lt;/name&gt;
     &lt;url&gt;http:<span class="code-comment">//repo.open.iona.com/maven2&lt;/url&gt;
</span>     &lt;snapshots&gt;
       &lt;enabled&gt;<span class="code-keyword">false</span>&lt;/enabled&gt;
     &lt;/snapshots&gt;
     &lt;releases&gt;
       &lt;enabled&gt;<span class="code-keyword">true</span>&lt;/enabled&gt;
     &lt;/releases&gt;
   &lt;/repository&gt;</pre>
</div></div>

<h3><a name="BookComponentAppendix-BuildingFromSource"></a>Building From Source</h3>

<p>The source for camel-javaspace is available here: <span class="nobr"><a href="https://projects.open.iona.com/projects/svn/iona/camel/trunk/components/camel-javaspace/" title="Visit page outside Confluence" rel="nofollow">https://projects.open.iona.com/projects/svn/iona/camel/trunk/components/camel-javaspace/<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></p>

<p>You'll need to register with <span class="nobr"><a href="http://open.iona.com" title="Visit page outside Confluence" rel="nofollow">http://open.iona.com<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> to be able to access subversion.</p>

<p>The full FUSE distro is here: <span class="nobr"><a href="https://projects.open.iona.com/projects/svn/iona/camel/trunk/" title="Visit page outside Confluence" rel="nofollow">https://projects.open.iona.com/projects/svn/iona/camel/trunk/<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></p>
<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-JBIComponent"></a>JBI Component</h2>

<p>The <b>jbi:</b> component is provided by the <span class="nobr"><a href="http://incubator.apache.org/servicemix/servicemix-camel.html" title="Visit page outside Confluence" rel="nofollow">ServiceMix Camel module<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> and provides integration with a JBI Normalized Message Router such as provided by <span class="nobr"><a href="http://incubator.apache.org/servicemix/" title="Visit page outside Confluence" rel="nofollow">Apache ServiceMix<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></p>

<p>Following code</p>
<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"jbi:endpoint:http:<span class="code-comment">//foo.bar.org/MyService/MyEndpoint"</span>)</span></pre>
</div></div>
<p>automatically exposes new endpoint to the bus where service qname is {<span class="nobr"><a href="http://foo.bar.org" title="Visit page outside Confluence" rel="nofollow">http://foo.bar.org<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>}MyService and endpoint name is MyEndpoint (refer to URI format later).</p>

<p>All that has to be done to use this endpoint is to send messages from some endpoint already declared (for example with <tt>jms:endpoint</tt>) to this JBI camel endpoint (the same way as messages are sent to EIP endpoints or any other endpoint) and camel will pick it up the same way as it picks any other messages.</p>

<p>Sending works in the same way:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">to(<span class="code-quote">"jbi:endpoint:http:<span class="code-comment">//foo.bar.org/MyService/MyEndpoint"</span>)</span></pre>
</div></div>
<p>Is used to send messages to JBI endpoint already deployed to the bus. It could be an endpoint exposed by <tt>jms:endpoint</tt>, <tt>http:provider</tt> or anything else.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">jbi:service:serviceNamespace[sep]serviceName
jbi:endpoint:serviceNamespace[sep]serviceName[sep]endpointName
jbi:name:endpointName</pre>
</div></div>

<p>The separator used will be:</p>
<ul>
	<li>'/' if the namespace looks like 'http://'</li>
	<li>':' if the namespace looks like 'urn:foo:bar'</li>
</ul>


<p>For more details of valid JBI URIs see the <span class="nobr"><a href="http://incubator.apache.org/servicemix/uris.html" title="Visit page outside Confluence" rel="nofollow">ServiceMix URI Guide<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. </p>

<p>Using the <b>jbi:service:</b> or <b>jbi:endpoint:</b> URI forms will set the service QName on the JBI endpoint to the exact one you give. Otherwise the default Camel JBI Service QName will be used which is</p>

<div class="code"><div class="codeContent">
<pre class="code-java">{http:<span class="code-comment">//activemq.apache.org/camel/schema/jbi}endpoint</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-Examples"></a>Examples</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">jbi:service:http:<span class="code-comment">//foo.bar.org/MyService
</span>jbi:endpoint:urn:foo:bar:MyService:MyEndpoint
jbi:endpoint:http:<span class="code-comment">//foo.bar.org/MyService/MyEndpoint
</span>jbi:name:cheese</pre>
</div></div>

<h3><a name="BookComponentAppendix-CreatingaJBIServiceUnit"></a>Creating a JBI Service Unit</h3>

<p>If you have some Camel routes you want to deploy inside JBI as a Service Unit you can use the <a href="/confluence/display/CAMEL/JBI+Service+Unit+Archetype" title="JBI Service Unit Archetype">JBI Service Unit Archetype</a> to create a new project.</p>

<p>If you have an existing maven project which you need to convert into a JBI Service Unit you may want to refer to the <span class="nobr"><a href="http://incubator.apache.org/servicemix/maven-jbi-plugin.html" title="Visit page outside Confluence" rel="nofollow">ServiceMix Maven JBI Plugins<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> for further help. Basically you just need to make sure</p>

<ul>
	<li>you have a spring XML file at <b>src/main/resources/camel-context.xml</b> which is used to boot up your routes inside the JBI Service Unit</li>
	<li>you change the pom's packaging to <b>jbi-service-unit</b></li>
</ul>


<p>Your pom.xml should look something like this to enable the jbi-service-unit packaging. </p>

<div class="code"><div class="codeContent">
<pre class="code-java">&lt;project xmlns=<span class="code-quote">"http:<span class="code-comment">//maven.apache.org/POM/4.0.0"</span> xmlns:xsi=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
</span>         xsi:schemaLocation=<span class="code-quote">"http:<span class="code-comment">//maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"</span>&gt;
</span>
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

  &lt;groupId&gt;myGroupId&lt;/groupId&gt;
  &lt;artifactId&gt;myArtifactId&lt;/artifactId&gt;
  &lt;packaging&gt;jbi-service-unit&lt;/packaging&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;

  &lt;name&gt;A Camel based JBI Service Unit&lt;/name&gt;

  &lt;url&gt;http:<span class="code-comment">//www.myorganization.org&lt;/url&gt;
</span>
  &lt;properties&gt;
    &lt;camel-version&gt;1.0.0&lt;/camel-version&gt;
    &lt;servicemix-version&gt;3.2-incubating&lt;/servicemix-version&gt;
  &lt;/properties&gt;

  &lt;dependencies&gt;
    &lt;dependency&gt;
      &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
      &lt;artifactId&gt;camel-jbi&lt;/artifactId&gt;
      &lt;version&gt;${camel-version}&lt;/version&gt;
    &lt;/dependency&gt;

    &lt;dependency&gt;
      &lt;groupId&gt;org.apache.servicemix&lt;/groupId&gt;
      &lt;artifactId&gt;servicemix-core&lt;/artifactId&gt;
      &lt;version&gt;${servicemix-version}&lt;/version&gt;
      &lt;scope&gt;provided&lt;/scope&gt;
    &lt;/dependency&gt;
  &lt;/dependencies&gt;

  &lt;build&gt;
    &lt;defaultGoal&gt;install&lt;/defaultGoal&gt;

    &lt;plugins&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
        &lt;configuration&gt;
          &lt;source&gt;1.5&lt;/source&gt;
          &lt;target&gt;1.5&lt;/target&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;

      &lt;!-- creates the JBI deployment unit --&gt;
      &lt;plugin&gt;
        &lt;groupId&gt;org.apache.servicemix.tooling&lt;/groupId&gt;
        &lt;artifactId&gt;jbi-maven-plugin&lt;/artifactId&gt;
        &lt;version&gt;${servicemix-version}&lt;/version&gt;
        &lt;extensions&gt;<span class="code-keyword">true</span>&lt;/extensions&gt;
      &lt;/plugin&gt;
    &lt;/plugins&gt;
  &lt;/build&gt;
&lt;/project&gt;</pre>
</div></div>


<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<ul>
	<li><span class="nobr"><a href="http://incubator.apache.org/servicemix/servicemix-camel.html" title="Visit page outside Confluence" rel="nofollow">ServiceMix Camel module<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
	<li><span class="nobr"><a href="http://servicemix.apache.org/3-beginner-using-apache-camel-inside-servicemix.html" title="Visit page outside Confluence" rel="nofollow">Using Camel with ServiceMix<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
</ul>

<h2><a name="BookComponentAppendix-JCRComponent"></a>JCR Component</h2>

<p>The <b><tt>jcr:</tt></b> component allows you to add nodes to a JCR (JSR-170) compliant content repository (e.g. <span class="nobr"><a href="http://jackrabbit.apache.org/" title="Visit page outside Confluence" rel="nofollow">Apache Jackrabbit <sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>).</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">jcr:<span class="code-comment">//user:password@repository/path/to/node</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-Usage"></a>Usage</h3>
<p>The <tt>repository</tt> element of the URI is used to look up the JCR <tt>Repository</tt> object in the Camel context registry.</p>

<p>If a message is sent to a producer endpoint created by this component:</p>
<ul>
	<li>a new node is created in the content repository</li>
	<li>all the message properties of the <tt>in</tt> message will be transformed to JCR <tt>Value</tt> instances and added to the new node</li>
	<li>the node's UUID is returned in the <tt>out</tt> message</li>
</ul>


<h3><a name="BookComponentAppendix-Messageproperties"></a>Message properties</h3>
<p>All message properties are converted to node properties, except for the <tt>org.apache.camel.component.jcr.node_name</tt> (you can refer to <tt>JcrComponent.NODE_NAME</tt> in your code), which is used to determine the node name.</p>

<h3><a name="BookComponentAppendix-Example"></a>Example</h3>
<p>The snippet below will create a node named <tt>node</tt> under the <tt>/home/test</tt> node in the content repository.  One additional attribute will be added to the node as well: <tt>my.contents.property</tt> will contain the body of the message being sent.</p>
<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"direct:a"</span>).setProperty(JcrComponent.NODE_NAME, constant(<span class="code-quote">"node"</span>))
    .setProperty(<span class="code-quote">"my.contents.property"</span>, body()).to(<span class="code-quote">"jcr:<span class="code-comment">//user:pass@repository/home/test"</span>);</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-JDBCComponent"></a>JDBC Component</h2>

<p>The <b>jdbc:</b> component allows you to work with databases using JDBC queries and operations via SQL text as the message payload.<br/>
This component uses standard Java JDBC to work with the database, unlike the <a href="/confluence/display/CAMEL/SQL+Component" title="SQL Component">SQL Component</a> component that uses spring-jdbc. </p>

<table cellpadding='5' width='85%' cellspacing='8px' class='warningMacro' border="0" align='center'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>
<p>So far endpoints from this component could be used only as producers. It means that you cannot use them in <tt>from()</tt> statement.</p></td></tr></table>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">jdbc:dataSourceName?options</pre>
</div></div>

<p>This component only supports producer, meaning that you can not use routes with this component in the <tt>from</tt> type.</p>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> readSize </td>
<td class='confluenceTd'> 2000 </td>
<td class='confluenceTd'> The default maximum number of rows that can be read by a polling query </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Result"></a>Result</h3>
<p>The result is returned in the out body as a <tt>ArrayList&lt;HashMap&lt;String, Object&gt;&gt;</tt> list object with the result. The List contains the list of rows and the Map contains each row with the string key as the column name.</p>

<p><b>Note:</b> This component fetches ResultSetMetaData to be able to return the column name as the key in the Map.</p>

<p>If the query is an update query the update count is returned in the header <tt>jdbc.updateCount</tt></p>

<h3><a name="BookComponentAppendix-Samples"></a>Samples</h3>

<p>In the sample below we fetches the rows from the customer table.</p>

<p>First we register our datasource in the Camel registry as testdb:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">JndiRegistry reg = <span class="code-keyword">super</span>.createRegistry();
reg.bind(<span class="code-quote">"testdb"</span>, ds);
<span class="code-keyword">return</span> reg;</pre>
</div></div>

<p>Then we configure a route that routes to the JDBC component so the SQL will be executed, notice that we refer to the testdb datasource that was bound in the previous step:</p>
<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-comment">// lets add simple route
</span><span class="code-keyword">public</span> void configure() <span class="code-keyword">throws</span> Exception {
    from(<span class="code-quote">"direct:hello"</span>).to(<span class="code-quote">"jdbc:testdb?readSize=100"</span>);
}</pre>
</div></div>

<p>And then we create the endpoint and sends the exchange containing the SQL query to execute in the in body. The result is returned in the out body.</p>
<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-comment">// first we create our exchange using the endpoint
</span>Endpoint endpoint = context.getEndpoint(<span class="code-quote">"direct:hello"</span>);
Exchange exchange = endpoint.createExchange();
<span class="code-comment">// then we set the SQL on the in body
</span>exchange.getIn().setBody(<span class="code-quote">"select * from customer order by ID"</span>);

<span class="code-comment">// now we send the exchange to the endpoint, and receives the response from Camel
</span>Exchange out = template.send(endpoint, exchange);

<span class="code-comment">// assertions of the response
</span>assertNotNull(out);
assertNotNull(out.getOut());
ArrayList&lt;HashMap&lt;<span class="code-object">String</span>, <span class="code-object">Object</span>&gt;&gt; data = out.getOut().getBody(ArrayList.class);
assertNotNull(<span class="code-quote">"out body could not be converted to an ArrayList - was: "</span>
    + out.getOut().getBody(), data);
assertEquals(2, data.size());
HashMap&lt;<span class="code-object">String</span>, <span class="code-object">Object</span>&gt; row = data.get(0);
assertEquals(<span class="code-quote">"cust1"</span>, row.get(<span class="code-quote">"ID"</span>));
assertEquals(<span class="code-quote">"jstrachan"</span>, row.get(<span class="code-quote">"NAME"</span>));
row = data.get(1);
assertEquals(<span class="code-quote">"cust2"</span>, row.get(<span class="code-quote">"ID"</span>));
assertEquals(<span class="code-quote">"nsandhu"</span>, row.get(<span class="code-quote">"NAME"</span>));</pre>
</div></div>

<h3><a name="BookComponentAppendix-SamplePollingthedatabaseeveryminute"></a>Sample - Polling the database every minute</h3>
<p>If we want to poll a database using this component we need to combine this with a polling scheduler such as the <a href="/confluence/display/CAMEL/Timer" title="Timer">Timer</a> or <a href="/confluence/display/CAMEL/Quartz" title="Quartz">Quartz</a> etc.<br/>
In this sample we retrieve data from the database every 60th seconds.</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"timer:<span class="code-comment">//foo?period=60000"</span>).setBody(constant(<span class="code-quote">"select * from customer"</span>)).to(<span class="code-quote">"jdbc:testdb"</span>).to(<span class="code-quote">"activemq:queue:customers"</span>);</span></pre>
</div></div>


<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-JettyComponent"></a>Jetty Component</h2>

<p>The <b>jetty:</b> component provides HTTP based <a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">endpoints</a> for consuming HTTP requests that arrive at an http endpoint.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">jetty:http:hostname[:port][/resourceUri][?options]</pre>
</div></div>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Example </th>
<th class='confluenceTh'> Required? </th>
<th class='confluenceTh'> default value </th>
</tr>
<tr>
<td class='confluenceTd'> sessionSupport </td>
<td class='confluenceTd'> The option for enable the session manager in the server side of Jetty. </td>
<td class='confluenceTd'> sessionSupport=true </td>
<td class='confluenceTd'> No </td>
<td class='confluenceTd'> false </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Usage"></a>Usage</h3>

<p>You can only consume from endpoints generated by the Jetty component.  Therefore it should only be used as input into your camel Routes.  To issue HTTP requests against other HTTP endpoints you can use the <a href="/confluence/display/CAMEL/HTTP" title="HTTP">HTTP Component</a></p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>


<h3><a name="BookComponentAppendix-Example"></a>Example</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"timer:<span class="code-comment">//foo?fixedRate=<span class="code-keyword">true</span>&amp;delay=0&amp;period=10000"</span>).to(<span class="code-quote">"jetty:http://www.google.com"</span>).setHeader(FileComponent.HEADER_FILE_NAME, <span class="code-quote">"message.html"</span>).to(<span class="code-quote">"file:target/hello"</span>);</span></pre>
</div></div>

<p>Poll the google homepage every 10 seconds and write the page to the file message.html</p>
<h2><a name="BookComponentAppendix-JingComponent"></a>Jing Component</h2>

<p>The Jing component uses the <span class="nobr"><a href="http://www.thaiopensource.com/relaxng/jing.html" title="Visit page outside Confluence" rel="nofollow">Jing Library<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> to perform XML validation of the message body using either</p>

<ul>
	<li><span class="nobr"><a href="http://relaxng.org/" title="Visit page outside Confluence" rel="nofollow">RelaxNG XML Syntax<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
	<li><span class="nobr"><a href="http://relaxng.org/compact-tutorial-20030326.html" title="Visit page outside Confluence" rel="nofollow">RelaxNG Compact Syntax<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
</ul>


<p>Note that the <a href="/confluence/display/CAMEL/MSV" title="MSV">MSV</a> component can also support RelaxNG XML syntax.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">rng:someLocalOrRemoteResource
rnc:someLocalOrRemoteResource</pre>
</div></div>

<p>Where <b>rng</b> means use the <span class="nobr"><a href="http://relaxng.org/" title="Visit page outside Confluence" rel="nofollow">RelaxNG XML Syntax<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> whereas <b>rnc</b> means use <span class="nobr"><a href="http://relaxng.org/compact-tutorial-20030326.html" title="Visit page outside Confluence" rel="nofollow">RelaxNG Compact Syntax<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. The following examples show possible URI values</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>Example</th>
<th class='confluenceTh'>Description</th>
</tr>
<tr>
<td class='confluenceTd'>rng:foo/bar.rng</td>
<td class='confluenceTd'> Will take the XML file <b>foo/bar.rng</b> on the classpath </td>
</tr>
<tr>
<td class='confluenceTd'>rnc:<span class="nobr"><a href="http://foo.com/bar.rnc" title="Visit page outside Confluence" rel="nofollow">http://foo.com/bar.rnc<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></td>
<td class='confluenceTd'>Will use the RelaxNG Compact Syntax file from the URL <span class="nobr"><a href="http://foo.com/bar.rnc" title="Visit page outside Confluence" rel="nofollow">http://foo.com/bar.rnc<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Example"></a>Example</h3>

<p>The following <span class="nobr"><a href="http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-jing/src/test/resources/org/apache/camel/component/validator/jing/rnc-context.xml" title="Visit page outside Confluence" rel="nofollow">example<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> shows how to configure a route from endpoint <b>direct:start</b> which then goes to one of two endpoints, either <b>mock:valid</b> or <b>mock:invalid</b> based on whether or not the XML matches the given <span class="nobr"><a href="http://relaxng.org/compact-tutorial-20030326.html" title="Visit page outside Confluence" rel="nofollow">RelaxNG Compact Syntax<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> schema (which is supplied on the classpath).</p>

<div class="code"><div class="codeContent">
<pre class="code-xml"><span class="code-tag">&lt;camelContext xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>
  <span class="code-tag">&lt;route&gt;</span>
    <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:start"</span>/&gt;</span>
    <span class="code-tag">&lt;try&gt;</span>
      <span class="code-tag">&lt;to uri=<span class="code-quote">"rnc:org/apache/camel/component/validator/jing/schema.rnc"</span>/&gt;</span>
      <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:valid"</span>/&gt;</span>

      <span class="code-tag">&lt;catch&gt;</span>
        <span class="code-tag">&lt;exception&gt;</span>org.apache.camel.ValidationException<span class="code-tag">&lt;/exception&gt;</span>
        <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:invalid"</span>/&gt;</span>
      <span class="code-tag">&lt;/catch&gt;</span>
    <span class="code-tag">&lt;/try&gt;</span>
  <span class="code-tag">&lt;/route&gt;</span>
<span class="code-tag">&lt;/camelContext&gt;</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-JMSComponent"></a>JMS Component</h2>

<p>The JMS component allows messages to be sent to a <span class="nobr"><a href="http://java.sun.com/products/jms/" title="Visit page outside Confluence" rel="nofollow">JMS<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> Queue or Topic; or messages to be consumed from a JMS Queue or Topic. The implementation of the JMS Component uses Spring's JMS support for declarative transactions, using Spring's JmsTemplate for sending and a MessageListenerContainer for consuming.</p>


<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">jms:[topic:]destinationName?properties</pre>
</div></div>

<p>So for example to send to queue FOO.BAR you would use</p>

<div class="code"><div class="codeContent">
<pre class="code-java">jms:FOO.BAR</pre>
</div></div>

<p>You can be completely specific if you wish via</p>

<div class="code"><div class="codeContent">
<pre class="code-java">jms:queue:FOO.BAR</pre>
</div></div>


<p>If you want to send to a topic called Stocks.Prices then you would use</p>

<div class="code"><div class="codeContent">
<pre class="code-java">jms:topic:Stocks.Prices</pre>
</div></div>

<h4><a name="BookComponentAppendix-UsingTemporaryDestinations"></a>Using Temporary Destinations</h4>

<p>As of 1.4.0 of Camel you can use temporary queues using the following URL format</p>

<div class="code"><div class="codeContent">
<pre class="code-java">jms:temp:queue:foo</pre>
</div></div>

<p>or temporary topics as</p>

<div class="code"><div class="codeContent">
<pre class="code-java">jms:temp:topic:bar</pre>
</div></div>

<p>Where <b>foo</b> and <b>bar</b>, the text after the String <b>jms:temp:queue:</b> or <b>jms:temp:topic:</b>, are the names of the destinations. This enables multiple routes or processors or beans to refer to the same temporary destination. e.g. you can create 3 temporary destinations and use them in routes as inputs or outputs by referring to them by name.</p>

<h3><a name="BookComponentAppendix-Notes"></a>Notes</h3>

<p>If you wish to use durable topic subscriptions, you need to specify both <b>clientId</b> and <b>durableSubscriberName</b>. Note that the value of the clientId must be unique and can only be used by a single JMS connection instance in your entire network. You may prefer to use <span class="nobr"><a href="http://activemq.apache.org/virtual-destinations.html" title="Visit page outside Confluence" rel="nofollow">Virtual Topics<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> instead to avoid this limitation. More background on durable messaging <span class="nobr"><a href="http://activemq.apache.org/how-do-durable-queues-and-topics-work.html" title="Visit page outside Confluence" rel="nofollow">here<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>.</p>

<p>When using message headers; the JMS specification states that header names must be valid Java identifiers. So by default camel will ignore any headers which do not match this rule. So try name your headers as if they are valid Java identifiers. One added bonus of this is that you can then use your headers inside a JMS Selector - which uses SQL92 syntax which mandates Java identifier syntax for headers.</p>

<p>From Camel 1.4 a simple strategy for mapping headers names is used by default. The strategy is to replace any dots in the headername with underscore, and vice-versa when the header name is restored from the JMS message that was sent over the wire. What does this means? No more loosing method names to invoke on a bean component, no more loosing the filename header for the File Component etc. </p>

<p>Current header name strategy used for accepting header names in Camel:</p>
<ul class="alternate" type="square">
	<li>replace all dots with underscores (e.g. <tt>org.apache.camel.MethodName</tt> =&gt; <tt>org_apache_camel_MethodName</tt>)</li>
	<li>test if the name is a valid java identifier using the JDK core classes</li>
	<li>if test success then the header is added and sent over the wire, if not its dropped (logged at DEBUG level)</li>
</ul>


<table cellpadding='5' width='85%' cellspacing='8px' class='infoMacro' border="0" align='center'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b class="strong">If you are using ActiveMQ</b><br />
<p>Note that the JMS component reuses Spring 2's JmsTemplate for sending messages. This is not ideal for use in a non-J2EE container and typically requires some caching JMS provider to avoid performance <span class="nobr"><a href="http://activemq.apache.org/jmstemplate-gotchas.html" title="Visit page outside Confluence" rel="nofollow">being lousy<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>.</p>

<p>So if you intent to use <span class="nobr"><a href="http://activemq.apache.org/" title="Visit page outside Confluence" rel="nofollow">Apache ActiveMQ<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> as your Message Broker - which is a good choice as ActiveMQ rocks <img class="emoticon" src="/confluence/images/icons/emoticons/smile.gif" height="20" width="20" align="absmiddle" alt="" border="0"/>, then we recommend that you either</p>

<ul>
	<li>use the <a href="/confluence/display/CAMEL/ActiveMQ" title="ActiveMQ">ActiveMQ</a> component which is already configured to use ActiveMQ efficiently</li>
	<li>use the PoolingConnectionFactory in ActiveMQ</li>
</ul>
</td></tr></table>

<table cellpadding='5' width='85%' cellspacing='8px' class='warningMacro' border="0" align='center'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b class="strong">For Consuming Messages cacheLevelName settings are vital!</b><br />
<p>If you are using Spring before 2.5.1 and Camel before 1.3.0 then you might want to set the <b>cacheLevelName</b> to be CACHE_CONSUMER for maximum performance. </p>

<p>Due to a <span class="nobr"><a href="http://opensource.atlassian.com/projects/spring/browse/SPR-3890" title="Visit page outside Confluence" rel="nofollow">bug in earlier Spring versions<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> causing a lack of transactional integrity, previous versions of Camel and Camel versions from 1.3.0 onwwards when used with earlier Spring versions than 2.5.1 will default to use CACHE_CONNECTION. See the JIRAs <span class="nobr"><a href="https://issues.apache.org/activemq/browse/CAMEL-163" title="Visit page outside Confluence" rel="nofollow">CAMEL-163<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> and <span class="nobr"><a href="https://issues.apache.org/activemq/browse/CAMEL-294" title="Visit page outside Confluence" rel="nofollow">CAMEL-294<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>.</p>

<p>Also if you are using XA or running in a J2EE container then you may want to set the <b>cacheLevelName</b> to be CACHE_NONE as we have seen using JBoss with TibCo EMS and JTA/XA you must disable caching.</p></td></tr></table>


<h3><a name="BookComponentAppendix-Properties"></a>Properties</h3>

<p>You can configure lots of different properties on the JMS endpoint which map to properties on the <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-jms/apidocs/org/apache/camel/component/jms/JmsConfiguration.html" title="Visit page outside Confluence" rel="nofollow">JMSConfiguration POJO<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>.</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Property </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> acceptMessagesWhileStopping </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Should the consumer accept messages while it is stopping </td>
</tr>
<tr>
<td class='confluenceTd'> acknowledgementModeName </td>
<td class='confluenceTd'> "AUTO_ACKNOWLEDGE" </td>
<td class='confluenceTd'> The JMS acknowledgement name which is one of: TRANSACTED, CLIENT_ACKNOWLEDGE, AUTO_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE </td>
</tr>
<tr>
<td class='confluenceTd'> autoStartup </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Should the consumer container auto-startup </td>
</tr>
<tr>
<td class='confluenceTd'> cacheLevelName </td>
<td class='confluenceTd'> "CACHE_CONNECTION" but when <span class="nobr"><a href="http://opensource.atlassian.com/projects/spring/browse/SPR-3890" title="Visit page outside Confluence" rel="nofollow">SPR-3890<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> is fixed it will be "CACHE_CONSUMER" </td>
<td class='confluenceTd'> Sets the cache level name for the underlying JMS resources </td>
</tr>
<tr>
<td class='confluenceTd'> clientId </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> Sets the JMS client ID to use. Note that this value if specified must be unique and can only be used by a single JMS connection instance. Its typically only required for durable topic subscriptions. You may prefer to use <span class="nobr"><a href="http://activemq.apache.org/virtual-destinations.html" title="Visit page outside Confluence" rel="nofollow">Virtual Topics<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> instead </td>
</tr>
<tr>
<td class='confluenceTd'> concurrentConsumers </td>
<td class='confluenceTd'> 1 </td>
<td class='confluenceTd'> Specifies the default number of concurrent consumers </td>
</tr>
<tr>
<td class='confluenceTd'> connectionFactory </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The default JMS connection factory to use for the <em>listenerConnectionFactory</em> and <em>templateConnectionFactory</em> if neither are specified </td>
</tr>
<tr>
<td class='confluenceTd'> deliveryPersistent </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Is persistent delivery used by default? </td>
</tr>
<tr>
<td class='confluenceTd'> disableReplyTo </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Do you want to ignore the JMSReplyTo header and so treat messages as InOnly by default and not send a reply back? </td>
</tr>
<tr>
<td class='confluenceTd'> durableSubscriptionName </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The durable subscriber name for specifying durable topic subscriptions </td>
</tr>
<tr>
<td class='confluenceTd'> exceptionListener </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The JMS Exception Listener used to be notified of any underlying JMS exceptions </td>
</tr>
<tr>
<td class='confluenceTd'> explicitQosEnabled </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Set if the deliveryMode, priority or timeToLive should be used when sending messages </td>
</tr>
<tr>
<td class='confluenceTd'> exposeListenerSession </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Set if the listener session should be exposed when consuming messages </td>
</tr>
<tr>
<td class='confluenceTd'> idleTaskExecutionLimit </td>
<td class='confluenceTd'> 1 </td>
<td class='confluenceTd'> Specify the limit for idle executions of a receive task, not having received any message within its execution. If this limit is reached, the task will shut down and leave receiving to other executing tasks (in case of dynamic scheduling; see the "maxConcurrentConsumers" setting). </td>
</tr>
<tr>
<td class='confluenceTd'> listenerConnectionFactory </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The JMS connection factory used for consuming messages </td>
</tr>
<tr>
<td class='confluenceTd'> maxConcurrentConsumers </td>
<td class='confluenceTd'> 1 </td>
<td class='confluenceTd'> Specifies the maximum number of concurrent consumers </td>
</tr>
<tr>
<td class='confluenceTd'> maxMessagesPerTask </td>
<td class='confluenceTd'> 1 </td>
<td class='confluenceTd'> The number of messages per task </td>
</tr>
<tr>
<td class='confluenceTd'> messageConverter </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The Spring Message Converter </td>
</tr>
<tr>
<td class='confluenceTd'> messageIdEnabled </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> When sending, should message IDs be added </td>
</tr>
<tr>
<td class='confluenceTd'> messageTimestampEnabled </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Should timestamps be enabled by default on sending messages </td>
</tr>
<tr>
<td class='confluenceTd'> priority </td>
<td class='confluenceTd'> -1 </td>
<td class='confluenceTd'> Values of &gt; 1 specify the message priority when sending, if the explicitQosEnabled property is specified </td>
</tr>
<tr>
<td class='confluenceTd'> selector </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> Sets the JMS Selector which is an SQL 92 predicate used to apply to messages to filter them at the message broker. You may have to encode special characters such as = as %3D </td>
</tr>
<tr>
<td class='confluenceTd'> receiveTimeout </td>
<td class='confluenceTd'> none </td>
<td class='confluenceTd'> The timeout when receiving messages </td>
</tr>
<tr>
<td class='confluenceTd'> recoveryInterval </td>
<td class='confluenceTd'> none </td>
<td class='confluenceTd'> The recovery interval </td>
</tr>
<tr>
<td class='confluenceTd'> serverSessionFactory </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The JMS ServerSessionFactory if you wish to use ServerSessionFactory for consumption </td>
</tr>
<tr>
<td class='confluenceTd'> subscriptionDurable </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Enabled by default if you specify a durableSubscriberName and a clientId </td>
</tr>
<tr>
<td class='confluenceTd'> taskExecutor </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> Allows you to specify a custom task executor for consuming messages </td>
</tr>
<tr>
<td class='confluenceTd'> templateConnectionFactory </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The JMS connection factory used for sending messages </td>
</tr>
<tr>
<td class='confluenceTd'> timeToLive </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> Is a time to live specified when sending messages </td>
</tr>
<tr>
<td class='confluenceTd'> transacted </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Is transacted mode used for sending/receiving messages? </td>
</tr>
<tr>
<td class='confluenceTd'> transactionManager </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The Spring transaction manager to use </td>
</tr>
<tr>
<td class='confluenceTd'> transactionName </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The name of the transaction to use </td>
</tr>
<tr>
<td class='confluenceTd'> transactionTimeout </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The timeout value of the transaction if using transacted mode </td>
</tr>
<tr>
<td class='confluenceTd'> useVersion102 </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Should the old JMS API be used </td>
</tr>
</tbody></table>


<h3><a name="BookComponentAppendix-Messageformat"></a>Message format</h3>
<p>The exchange that is sent over the JMS wire must conform to the <span class="nobr"><a href="http://java.sun.com/j2ee/1.4/docs/api/javax/jms/Message.html" title="Visit page outside Confluence" rel="nofollow">JMS Message spec<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>.</p>

<p>For the <tt>exchange.in.header</tt> the following rules apply for the <b>keys</b>:</p>
<ul class="alternate" type="square">
	<li>Keys stating with JMS or JMSX is reserved. All user keys will be dropped.</li>
	<li><tt>exchange.in.headers</tt> keys must be literals and all be valid Java identifiers. (do not use dots in the key name)</li>
	<li>In Camel 1.4 onwards Camel will automatically replace all dots with underscore for key names. And vice-versa when Camel consumes JMS messages.</li>
</ul>


<p>For the <tt>exchange.in.header</tt> the following rules apply for the <b>values</b>:</p>
<ul class="alternate" type="square">
	<li>The values must be primitives or their counter objects (such as Integer, Long, Character). String, CharSequence, Date, BigDecimal or BigInteger is all converted to their <tt>toString()</tt> representation. All other types is dropped.</li>
</ul>


<p>Camel will log with category <tt>org.apache.camel.component.jms.JmsBinding</tt> at <b>DEBUG</b> level if it drops a given header value. Example:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">2008-07-09 06:43:04,046 [main           ] DEBUG JmsBinding                     - Ignoring non primitive header: order of class: org.apache.camel.component.jms.issues.DummyOrder with value: DummyOrder{orderId=333, itemId=4444, quantity=2}</pre>
</div></div>

<h3><a name="BookComponentAppendix-ConfiguringdifferentJMSproviders"></a>Configuring different JMS providers</h3>

<p>You can configure your JMS provider inside the <a href="/confluence/display/CAMEL/Spring" title="Spring">Spring</a> XML as follows... </p>

<div class="code"><div class="codeContent">
<pre class="code-xml"><span class="code-tag">&lt;camelContext id=<span class="code-quote">"camel"</span> xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>
<span class="code-tag">&lt;/camelContext&gt;</span>

<span class="code-tag">&lt;bean id=<span class="code-quote">"activemq"</span> class=<span class="code-quote">"org.apache.camel.component.jms.JmsComponent"</span>&gt;</span>
  <span class="code-tag">&lt;property name=<span class="code-quote">"connectionFactory"</span>&gt;</span>
    <span class="code-tag">&lt;bean class=<span class="code-quote">"org.apache.activemq.ActiveMQConnectionFactory"</span>&gt;</span>
      <span class="code-tag">&lt;property name=<span class="code-quote">"brokerURL"</span> value=<span class="code-quote">"vm://localhost?broker.persistent=false"</span>/&gt;</span>
    <span class="code-tag">&lt;/bean&gt;</span>
  <span class="code-tag">&lt;/property&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span></pre>
</div></div>

<p>Basically you can configure as many JMS component instances as you wish and give them <b>a unique name via the id attribute</b>. The above example configures an <em>'activemq'</em> component. You could do the same to configure MQSeries, TibCo, BEA, Sonic etc.</p>

<p>Once you have a named JMS component you can then refer to endpoints within that component using URIs. For example for the component name'activemq' you can then refer to destinations as <b>activemq:[queue:&#124;topic:]destinationName</b>. So you could use the same approach for working with all other JMS providers.</p>

<p>This works by the SpringCamelContext lazily fetching components from the spring context for the scheme name you use for <a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a> <a href="/confluence/display/CAMEL/URIs" title="URIs">URIs</a> and having the <a href="/confluence/display/CAMEL/Component" title="Component">Component</a> resolve the endpoint URIs. </p>

<h4><a name="BookComponentAppendix-EnablingTransactedConsumption"></a>Enabling Transacted Consumption</h4>

<p>A common requirement is to consume from a queue in a transaction then process the message using the Camel route. To do this just ensure you set the following properties on the component/endpoint</p>

<ul>
	<li>transacted = true</li>
	<li>transactionManager = a Transsaction Manager - typically the JmsTransactionManager</li>
</ul>


<h4><a name="BookComponentAppendix-UsingJNDItofindtheConnectionFactory"></a>Using JNDI to find the ConnectionFactory</h4>

<p>If you are using a J2EE container you might want to lookup in JNDI to find your ConnectionFactory rather than use the usual &lt;bean&gt; mechanism in spring. You can do this using Spring's factory bean or the new XML namespace. e.g.</p>

<div class="code"><div class="codeContent">
<pre class="code-java">&lt;bean id=<span class="code-quote">"weblogic"</span> class=<span class="code-quote">"org.apache.camel.component.jms.JmsComponent"</span>&gt;
  &lt;property name=<span class="code-quote">"connectionFactory"</span> ref=<span class="code-quote">"myConnectionFactory"</span>/&gt;
&lt;/bean&gt;

&lt;jee:jndi-lookup id=<span class="code-quote">"myConnectionFactory"</span> jndi-name=<span class="code-quote">"java:env/ConnectionFactory"</span>/&gt;</pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-JPAComponent"></a>JPA Component</h2>

<p>The <b>jpa:</b> component allows you to work with databases using JPA (EJB 3 Persistence) such as for working with OpenJPA, Hibernate, TopLink to work with relational databases.</p>

<h3><a name="BookComponentAppendix-Sendingtotheendpoint"></a>Sending to the endpoint</h3>

<p>Sending POJOs to the JPA endpoint inserts entities into the database. The body of the message is assumed to be an entity bean (i.e. a POJO with an <span class="nobr"><a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Entity.html" title="Visit page outside Confluence" rel="nofollow">@Entity<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> annotation on it). </p>

<p>If the body does not contain an entity bean then use a <a href="/confluence/display/CAMEL/Message+Translator" title="Message Translator">Message Translator</a> in front of the endpoint to perform the necessary conversion first.</p>

<h3><a name="BookComponentAppendix-Consumingfromtheendpoint"></a>Consuming from the endpoint</h3>

<p>Consuming messages removes (or updates) entities in the database. This allows you to use a database table as a logical queue, consumers take messages from the queue and then delete/update them to logically remove them from the queue.</p>

<p>If you do not wish to delete the entity when it has been processed you can specify <b>consumeDelete=false</b> on the URI. This will result in the entity being processed each poll.</p>

<p>If you would rather perform some update on the entity to mark it as processed (such as to exclude it from a future query) then you can annotate a method with <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-jpa/apidocs/org/apache/camel/component/jpa/Consumed.html" title="Visit page outside Confluence" rel="nofollow">@Consumed<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> which will be invoked on your entity bean when the entity bean is consumed.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">jpa:[entityClassName]</pre>
</div></div>

<p>For sending to the endpoint, the <b>entityClassName</b> is optional. If specified it is used to help use the <span class="nobr"><a href="/confluence/pages/createpage.action?spaceKey=CAMEL&amp;title=Type+Conversion&amp;linkCreation=true&amp;fromPageId=52099" title="Create Page: Type Conversion" class="createlink">Type Conversion<sup><img class="rendericon" src="/confluence/images/icons/plus.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> to ensure the body is of the correct type.</p>

<p>For consuming the <b>entityClassName</b> is mandatory.</p>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> entityType </td>
<td class='confluenceTd'> entityClassName </td>
<td class='confluenceTd'> Is the provided entityClassName from the URI </td>
</tr>
<tr>
<td class='confluenceTd'> persistenceUnit </td>
<td class='confluenceTd'> camel </td>
<td class='confluenceTd'> the JPA persistence unit used by default </td>
</tr>
<tr>
<td class='confluenceTd'> consumeDelete </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Option for JpaConsumer only. Enables / disables whether or not the entity is deleted after it is consumed. </td>
</tr>
<tr>
<td class='confluenceTd'> consumeLockEntity </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Option for JpaConsumer only. Enables / disables whether or not to use exclusive locking of each entity while processing the results from the pooling. </td>
</tr>
<tr>
<td class='confluenceTd'> flushOnSend </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Option for JpaProducer only. Flushes the <span class="nobr"><a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html" title="Visit page outside Confluence" rel="nofollow">EntityManager<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> after the entity beans has been persisted. </td>
</tr>
<tr>
<td class='confluenceTd'> maximumResults </td>
<td class='confluenceTd'> -1 </td>
<td class='confluenceTd'>  Option for JpaConsumer only. Set the maximum number of results to retrieve on the <span class="nobr"><a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html" title="Visit page outside Confluence" rel="nofollow">Query<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.delay </td>
<td class='confluenceTd'> 500 </td>
<td class='confluenceTd'> Option for JpaConsumer only. Delay in millis between each poll. </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.initialDelay </td>
<td class='confluenceTd'> 1000 </td>
<td class='confluenceTd'> Option for JpaConsumer only. Millis before polling starts. </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.userFixedDelay </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Option for JpaConsumer only. <b>true</b> to use fixed delay between pools, otherwise fixed rate is used. See <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html" title="Visit page outside Confluence" rel="nofollow">ScheduledExecutorService<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> in JDK for details. </td>
</tr>
</tbody></table>


<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-ListComponent"></a>List Component</h2>

<p>The List component provdes a simple <a href="/confluence/display/CAMEL/BrowsableEndpoint" title="BrowsableEndpoint">BrowsableEndpoint</a> which can be useful for testing, visualisation tools or debugging. The exchanges sent to the endpoint are all available to be browsed.</p>


<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">list:someName</pre>
</div></div>

<p>Where <b>someName</b> can be any string to uniquely identify the endpoint</p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-LogComponent"></a>Log Component</h2>

<p>The <b>log:</b> component logs message exchanges to the underlying logging mechanism.</p>

Camel uses <span class="nobr"><a href="http://commons.apache.org/logging/" title="Visit page outside Confluence" rel="nofollow">commons-logging<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> which allows you to configure logging via 

<ul>
	<li><span class="nobr"><a href="http://logging.apache.org/log4j/" title="Visit page outside Confluence" rel="nofollow">Log4j<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
	<li><span class="nobr"><a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/logging/package-summary.html" title="Visit page outside Confluence" rel="nofollow">JDK 1.4 logging<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
	<li>Avalon</li>
	<li>SimpleLog - a simple provider in commons-logging</li>
</ul>


<p>Refer to the <span class="nobr"><a href="http://commons.apache.org/logging/commons-logging-1.1.1/guide.html" title="Visit page outside Confluence" rel="nofollow">commons-logging user guide<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> for a more complete overview of how to use and configure commons-logging.</p>


<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">log:loggingCategory[?level=loggingLevel]</pre>
</div></div>

<p>Where <b>loggingCategory</b> is the name of the logging category to use and <b>loggingLevel</b> is the logging level such as DEBUG, INFO, WARN, ERROR - the default is INFO</p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<ul>
	<li><a href="/confluence/display/CAMEL/How+do+I+use+log4j" title="How do I use log4j">How do I use log4j</a></li>
	<li><a href="/confluence/display/CAMEL/How+do+I+use+Java+1.4+logging" title="How do I use Java 1.4 logging">How do I use Java 1.4 logging</a></li>
</ul>


<h2><a name="BookComponentAppendix-MailComponent"></a>Mail Component</h2>

<p>The mail component provides access to Email via Spring's Mail support and the underlying JavaMail system.</p>

<table cellpadding='5' width='85%' cellspacing='8px' class='infoMacro' border="0" align='center'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b class="strong">Default behavior changed</b><br />
<p>As of Camel 1.4 the default consumer delay is now 60 seconds. Camel will therefore only poll the mailbox once a minute to not exhaust the mail server. The default value in Camel 1.3 is 500 millis.</p></td></tr></table>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">smtp:<span class="code-comment">//[user-info@]host:port[?password=somepwd]
</span>pop3:<span class="code-comment">//[user-info@]host:port[?password=somepwd]
</span>imap:<span class="code-comment">//[user-info@]host:port[?password=somepwd]</span></pre>
</div></div>

<p>which supports either POP, IMAP or SMTP underlying protocols.</p>

<p>It is possible to omit the user-info and specify the username as a URI parameter instead</p>
<div class="code"><div class="codeContent">
<pre class="code-java">smtp:<span class="code-comment">//host:port?password=somepwd&amp;username=someuser</span></pre>
</div></div>
<p>Such as:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">smtp:<span class="code-comment">//mycompany.mailserver:30?password=tiger&amp;username=scott</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-SSLsupport"></a>SSL support</h3>
<p>Camel have support for secure mail protocols. Just add a s to the scheme such as:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">smtps:<span class="code-comment">//[user-info@]host:port[?password=somepwd]
</span>pop3s:<span class="code-comment">//[user-info@]host:port[?password=somepwd]
</span>imaps:<span class="code-comment">//[user-info@]host:port[?password=somepwd]</span></pre>
</div></div>

<table cellpadding='5' width='85%' cellspacing='8px' class='infoMacro' border="0" align='center'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b class="strong">SSL Information</b><br />
<p>Its the underlying mail framework that is handling the SSL support. Camel uses SUN JavaMail. However SUN JavaMail only trusts certificates issued by well known Certificate Authorities. So if you have issued your own certificate you have to import it into the local Java keystore file (see SSLNOTES.txt in JavaMail for details).</p>

<p>If you are using your own signed certificates sometimes it can be cumbersome to install your certificate in the local keystore. Camel provides a test option <b>dummyTrustManager</b> that when enabled will accept any given certificate.<br/>
<b>Notice:</b> this is strongly discouraged not using in production environments.</p></td></tr></table>

<h3><a name="BookComponentAppendix-MailMessageContent"></a>Mail Message Content</h3>
<p>Camel will use the Exchange Message IN body as the <span class="nobr"><a href="http://java.sun.com/javaee/5/docs/api/javax/mail/internet/MimeMessage.html" title="Visit page outside Confluence" rel="nofollow">MimeMessage<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> text content. The body is converted to String.class.</p>

<p>Camel copies all the Exchange Message IN headers to the <span class="nobr"><a href="http://java.sun.com/javaee/5/docs/api/javax/mail/internet/MimeMessage.html" title="Visit page outside Confluence" rel="nofollow">MimeMessage<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> headers. </p>

<p>The subject of the <span class="nobr"><a href="http://java.sun.com/javaee/5/docs/api/javax/mail/internet/MimeMessage.html" title="Visit page outside Confluence" rel="nofollow">MimeMessage<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> can be configured using a header property on the in message. The code below demonstrates this:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"direct:a"</span>).setHeader(<span class="code-quote">"subject"</span>, subject).to(<span class="code-quote">"smtp:<span class="code-comment">//james2@localhost"</span>);</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-DefaultPorts"></a>Default Ports</h3>
<p>As of Camel 1.4 support for default port number has been added. If the port number is omitted Camel will determine based on the protocol the port number to use.</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Protocol </th>
<th class='confluenceTh'> Default Port Number </th>
</tr>
<tr>
<td class='confluenceTd'> SMPT </td>
<td class='confluenceTd'> 25 </td>
</tr>
<tr>
<td class='confluenceTd'> SMPTS </td>
<td class='confluenceTd'> 465 </td>
</tr>
<tr>
<td class='confluenceTd'> POP3 </td>
<td class='confluenceTd'> 110 </td>
</tr>
<tr>
<td class='confluenceTd'> POP3S </td>
<td class='confluenceTd'> 995 </td>
</tr>
<tr>
<td class='confluenceTd'> IMAP </td>
<td class='confluenceTd'> 143 </td>
</tr>
<tr>
<td class='confluenceTd'> IMAPS </td>
<td class='confluenceTd'> 993 </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Property </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> host </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> The host name or IP address to connect to </td>
</tr>
<tr>
<td class='confluenceTd'> port </td>
<td class='confluenceTd'> See Default Ports </td>
<td class='confluenceTd'> The TCP port number to connect on </td>
</tr>
<tr>
<td class='confluenceTd'> user-info </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> The user name on the email server </td>
</tr>
<tr>
<td class='confluenceTd'> username </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> The user name on the email server configured as a URI parameter </td>
</tr>
<tr>
<td class='confluenceTd'> password </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The users password to use, can be omitted if the mail server does not require a password </td>
</tr>
<tr>
<td class='confluenceTd'> ignoreUriScheme </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> If enabled Camel will use the scheme to determine the transport protocol to use (pop, imap, smtp etc.) </td>
</tr>
<tr>
<td class='confluenceTd'> defaultEncoding </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The default encoding to use for MineMessages </td>
</tr>
<tr>
<td class='confluenceTd'> folderName </td>
<td class='confluenceTd'> INBOX </td>
<td class='confluenceTd'> The folder to poll </td>
</tr>
<tr>
<td class='confluenceTd'> destination </td>
<td class='confluenceTd'> user-info@host </td>
<td class='confluenceTd'> @deprecated use To option. The TO recipients (the receivers of the mail) </td>
</tr>
<tr>
<td class='confluenceTd'> to </td>
<td class='confluenceTd'> user-info@host </td>
<td class='confluenceTd'> The TO recipients (the receivers of the mail). This option is introduced in Camel 1.4. </td>
</tr>
<tr>
<td class='confluenceTd'> CC </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The CC recipients (the receivers of the mail). This option is introduced in Camel 1.4. </td>
</tr>
<tr>
<td class='confluenceTd'> BCC </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The BCC recipients (the receivers of the mail). This option is introduced in Camel 1.4. </td>
</tr>
<tr>
<td class='confluenceTd'> from </td>
<td class='confluenceTd'> camel@localhost </td>
<td class='confluenceTd'> The FROM email address </td>
</tr>
<tr>
<td class='confluenceTd'> deleteProcessedMessages </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Deletes the messages after they have been processed. This is done by setting the DELETED flag on the mail message. If <b>false</b> then the flag SEEN is set instead. </td>
</tr>
<tr>
<td class='confluenceTd'> processOnlyUnseenMessages </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> As of Camel 1.4 its possible to configure MailConsumer to only process unseen messages (eg new messages) or all. Note Camel will always skip deleted messages. Setting this option to <b>true</b> will filter to only unseen messages. </td>
</tr>
<tr>
<td class='confluenceTd'> fetchSize </td>
<td class='confluenceTd'> -1 </td>
<td class='confluenceTd'> As of Camel 1.4 a maximum number of messages to consume during a polling can be set. This can be used to not exhaust a mail server if a mailbox folder contains a lot of messages. Default value of -1 means no fetch size and all messages will be consumed. Setting the value to 0 is a special corner case where Camel will not consume any messages at all. </td>
</tr>
<tr>
<td class='confluenceTd'> debugMode </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> As of Camel 1.4 its possible to enable the debug mode on the underlying mail framework. SUN Mail framework will default output to System.out. </td>
</tr>
<tr>
<td class='confluenceTd'> connectionTimeout </td>
<td class='confluenceTd'> 30000 </td>
<td class='confluenceTd'> As of Camel 1.4 the connection timeout can be configured in millis. Default is 30 seconds. </td>
</tr>
<tr>
<td class='confluenceTd'> dummyTrustManager </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> As of Camel 1.4 testing SSL connections can be easier if enabling a dummy TrustManager that trust any given certificate. Notice this is only to be used for testing, as it does not provide any security at all. </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.initialDelay </td>
<td class='confluenceTd'> 1000 </td>
<td class='confluenceTd'> Millis before the polling starts </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.delay </td>
<td class='confluenceTd'> 60000 </td>
<td class='confluenceTd'> As of Camel 1.4 the default consumer delay is now 60 seconds. Camel will therefore only poll the mailbox once a minute to not exhaust the mail server. The default value in Camel 1.3 is 500 millis. </td>
</tr>
<tr>
<td class='confluenceTd'> consumer.useFixedDelay </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> <b>true</b> to use fixed delay between pools, otherwise fixed rate is used. See <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledExecutorService.html" title="Visit page outside Confluence" rel="nofollow">ScheduledExecutorService<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> in JDK for details. </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Samples"></a>Samples</h3>

<p>We start with a simple route that sends the messages received from a JMS queue as emails. The email account with be the admin account on mymailserver.com.</p>
<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"jms:<span class="code-comment">//queue:subscription"</span>).to(<span class="code-quote">"smtp://admin@mymailserver.com?password=secret"</span>);</span></pre>
</div></div>

<p>In the next sample we will poll a mailbox for new emails once every minute. Notice that we use the special consumer parameter for setting the poll interval <b>consumer.delay</b> as 60000 millis = 60 seconds.</p>
<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"imap:<span class="code-comment">//admin@mymailserver.com?password=secret&amp;processOnlyUnseenMessages=<span class="code-keyword">true</span>&amp;consumer.delay=60000"</span>).to(<span class="code-quote">"seda://mails"</span>);</span></pre>
</div></div>

<p>In this sample we want to send a mail to multiple recipients. This feature was introduced in camel 1.4.</p>
<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-comment">// all the recipients of <span class="code-keyword">this</span> mail are:
</span><span class="code-comment">// To: camel@riders.org , easy@riders.org
</span><span class="code-comment">// CC: me@you.org
</span><span class="code-comment">// BCC: someone@somewhere.org
</span><span class="code-object">String</span> recipients = <span class="code-quote">"&amp;To=camel@riders.org,easy@riders.org&amp;CC=me@you.org&amp;BCC=someone@somewhere.org"</span>;

from(<span class="code-quote">"direct:a"</span>).to(<span class="code-quote">"smtp:<span class="code-comment">//you@mymailserver.com?password=secret&amp;From=you@apache.org"</span> + recipients);</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-AttachmentSample"></a>Attachment Sample</h3>

<p>Attachments is a new feature in Camel 1.4 that of course is also supported by the mail component. In the sample below we send a mail message containing a plain text message with a logo file attachment.</p>
<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-comment">// create an exchange with a normal body and attachment to be produced as email
</span>Endpoint endpoint = context.getEndpoint(<span class="code-quote">"smtp:<span class="code-comment">//james@mymailserver.com?password=secret"</span>);
</span>
<span class="code-comment">// create the exchange with the mail message that is multipart with a file and a Hello World text/plain message.
</span>Exchange exchange = endpoint.createExchange();
Message in = exchange.getIn();
in.setBody(<span class="code-quote">"Hello World"</span>);
in.addAttachment(<span class="code-quote">"logo.jpeg"</span>, <span class="code-keyword">new</span> DataHandler(<span class="code-keyword">new</span> FileDataSource(<span class="code-quote">"src/test/data/logo.jpeg"</span>)));

<span class="code-comment">// create a producer that can produce the exchange (= send the mail)
</span>Producer producer = endpoint.createProducer();
<span class="code-comment">// start the producer
</span>producer.start();
<span class="code-comment">// and let it go (processes the exchange by sending the email)
</span>producer.process(exchange);</pre>
</div></div>

<h3><a name="BookComponentAppendix-SSLSample"></a>SSL Sample</h3>

<p>In this sample we want to poll our Google mail inbox for mails. Google mail requires to use SSL and have it configured for other clients to access your mailbox. This is done by logging into your google mail and change your settings to allow IMAP access. Google have extensive documentation how to do this.</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"imaps:<span class="code-comment">//imap.gmail.com?username=YOUR_USERNAME@gmail.com&amp;password=YOUR_PASSWORD&amp;deleteProcessedMessages=<span class="code-keyword">false</span>&amp;processOnlyUnseenMessages=<span class="code-keyword">true</span>&amp;consumer.delay=60000"</span>).to(<span class="code-quote">"log:newmail"</span>);</span></pre>
</div></div>

<p>The route above will poll the google mail inbox for new mails once every minute and log it to the newmail logger category.<br/>
Running the sample with DEBUG logging enabled we can monitor the progress in the logs:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">2008-05-08 06:32:09,640 DEBUG MailConsumer - Connecting to MailStore imaps<span class="code-comment">//imap.gmail.com:993 (SSL enabled), folder=INBOX
</span>2008-05-08 06:32:11,203 DEBUG MailConsumer - Polling mailfolder: imaps<span class="code-comment">//imap.gmail.com:993 (SSL enabled), folder=INBOX 
</span>2008-05-08 06:32:11,640 DEBUG MailConsumer - Fetching 1 messages. Total 1 messages. 
2008-05-08 06:32:12,171 DEBUG MailConsumer - Processing message: messageNumber=[332], from=[James Bond &lt;007@mi5.co.uk&gt;], to=YOUR_USERNAME@gmail.com], subject=[Camel mail component is now much better], sentDate=[2008-05-08 06:31:44], receivedDate=[2008-05-08 06:34:39] 
2008-05-08 06:32:12,187 INFO  newmail - Exchange[MailMessage: messageNumber=[332], from=[James Bond &lt;007@mi5.co.uk&gt;], to=YOUR_USERNAME@gmail.com], subject=[Camel mail component is now much better], sentDate=[2008-05-08 06:31:44], receivedDate=[2008-05-08 06:34:39]]</pre>
</div></div>

<h3><a name="BookComponentAppendix-SSLSamplewithdummyTrustManager"></a>SSL Sample with dummyTrustManager</h3>
<p>In the next sample we want to sent mails from Camel using our own mail server using secure connections. As our own mail server is using our own signed certificate we need either to</p>
<ol>
	<li>install our certificate in the local keystore Camel uses</li>
	<li>use the dummyTrustManager option for testing purpose to see if the secure communication works</li>
</ol>


<p>In the sample we use the dummyTrustManager option:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"seda:mailsToSend"</span>).to(<span class="code-quote">"imaps:<span class="code-comment">//ourmailsserver.com?username=camelmail&amp;password=secret&amp;dummyTrustManager=<span class="code-keyword">true</span>"</span>);</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-MINAComponent"></a>MINA Component</h2>

<p>The <b>mina:</b> component is a transport for working with <span class="nobr"><a href="http://mina.apache.org/" title="Visit page outside Confluence" rel="nofollow">Apache MINA<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">mina:tcp:<span class="code-comment">//hostname[:port]
</span>mina:udp:<span class="code-comment">//hostname[:port]
</span>mina:multicast:<span class="code-comment">//hostname[:port]
</span>mina:vm:<span class="code-comment">//hostname[:port}</span></pre>
</div></div>
<p>From Camel 1.3 onwards you can specify a codec in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a> using the <b>codec</b> option. If you are using TCP and no codec is specified then the textline flag is used to determine if text line based codec or object serialization should be used instead.</p>

<p>For UDP/Multicast if no codec is specified the default uses a basic ByteBuffer based codec.</p>

<p>Multicast also has a shorthand notation <b>mcast</b>.</p>

<p>The VM protocol is used as a direct forwarding mechanism in the same JVM. See the <span class="nobr"><a href="http://mina.apache.org/report/1.1/apidocs/org/apache/mina/transport/vmpipe/package-summary.html" title="Visit page outside Confluence" rel="nofollow">MINA VM-Pipe API documentation<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> for details.</p>

<p>A MinaProducer has a default timeout value of 30 seconds, while it waits for a response from the remote server.</p>

<p>In normal usage Camel-mina only supports marshalling the body content - message headers and exchange properties will not be sent.<br/>
However the option <b>transferExchange</b> does allow to transfer the exchange itself over the wire. See options below.</p>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> codec </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> As of 1.3 or later you can refer to a named ProtocolCodecFactory instance in your <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a> such as your Spring ApplicationContext which is then used for the marshalling </td>
</tr>
<tr>
<td class='confluenceTd'> textline </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> Only used for TCP. If no codec is specified then you can use this flag in 1.3 or later to indicate a text line based codec; if not specified or the value is false then Object Serialization is assumed over TCP. </td>
</tr>
<tr>
<td class='confluenceTd'> sync </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> As of 1.3 or later you can configure the exchange pattern to be either InOnly (default) or InOut. Setting sync=true means a synchronous exchange (InOut), where the client can read the response from MINA (The exchange out message). </td>
</tr>
<tr>
<td class='confluenceTd'> lazySessionCreation </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> As of 1.3 or later session can be lazy created to avoid exceptions if the remote server is not up and running when the Camel producer is started. </td>
</tr>
<tr>
<td class='confluenceTd'> timeout </td>
<td class='confluenceTd'> 30000 </td>
<td class='confluenceTd'> As of 1.3 or later you can configure the timeout while waiting for a response from a remote server. The timeout unit is in millis, so 60000 is 60 seconds. The timeout is only used for MinaProducer. </td>
</tr>
<tr>
<td class='confluenceTd'> encoding </td>
<td class='confluenceTd'> JVM Default </td>
<td class='confluenceTd'> As of 1.3 or later you can configure the encoding (is a <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/nio/charset/Charset.html" title="Visit page outside Confluence" rel="nofollow">charset name<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>) to use for the TCP textline codec and the UDP protocol. If not provided Camel will use the <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/nio/charset/Charset.html#defaultCharset()" title="Visit page outside Confluence" rel="nofollow">JVM default Charset<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. </td>
</tr>
<tr>
<td class='confluenceTd'> transferExchange </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Only used for TCP. As of 1.3 or later you can transfer the exchange over the wire instead of just the body. The following fields is transfered: in body, out body, in headers, out headers, exchange properties, exchange exception. </td>
</tr>
<tr>
<td class='confluenceTd'> minaLogger </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> As of 1.3 or later you can enable Apache MINA logging filter. Apache MINA uses slf4j logging at INFO level to log all input and output. </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-MockComponent"></a>Mock Component</h2>

Testing of distributed and asynchronous processing is notoriously difficult. The <a href="/confluence/display/CAMEL/Mock" title="Mock">Mock</a>, <a href="/confluence/display/CAMEL/Test" title="Test">Test</a> and <a href="/confluence/display/CAMEL/DataSet" title="DataSet">DataSet</a> endpoints work great with the <a href="/confluence/display/CAMEL/Spring+Testing" title="Spring Testing">Spring Testing</a> framework to simplify your unit and integration testing using <a href="/confluence/display/CAMEL/Enterprise+Integration+Patterns" title="Enterprise Integration Patterns">Enterprise Integration Patterns</a> and Camel's large range of <a href="/confluence/display/CAMEL/Components" title="Components">Components</a> together with the powerful <a href="/confluence/display/CAMEL/Mock" title="Mock">Mock</a> and <a href="/confluence/display/CAMEL/Test" title="Test">Test</a> testing endpoints.

<p>The Mock component provides a powerful declarative testing mechanism which is similar to <span class="nobr"><a href="http://jmock.org" title="Visit page outside Confluence" rel="nofollow">jMock<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> in that it allows declarative expectations to be created on any Mock endpoint before a test begins. Then the test is ran which typically fires messages to one or more endpoints and finally the expectations can be asserted in a test case to ensure the system  worked as expected. </p>


<p>This allows you to test various things like</p>

<ul>
	<li>the correct number of messages are received on each endpoint</li>
	<li>that the correct payloads are received, in the right order</li>
	<li>that messages arrive on an endpoint in order, using some <a href="/confluence/display/CAMEL/Expression" title="Expression">Expression</a> to create an order testing function</li>
	<li>that messages arrive match some kind of <a href="/confluence/display/CAMEL/Predicate" title="Predicate">Predicate</a> such as that specific headers have certain values, or that parts of the messages match some predicate such as by evaluating an <a href="/confluence/display/CAMEL/XPath" title="XPath">XPath</a> or <a href="/confluence/display/CAMEL/XQuery" title="XQuery">XQuery</a> <a href="/confluence/display/CAMEL/Expression" title="Expression">Expression</a></li>
</ul>


<p><b>Note</b> that there is also the <a href="/confluence/display/CAMEL/Test" title="Test">Test endpoint</a> which is-a Mock endpoint but which also uses a second endpoint to provide the list of expected message bodies and automatically sets up the Mock endpoint assertions. i.e. its a Mock endpoint which automatically sets up its assertions from some sample messages in a <a href="/confluence/display/CAMEL/File" title="File">File</a> or <a href="/confluence/display/CAMEL/JPA" title="JPA">database</a> for example.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">mock:someName</pre>
</div></div>

<p>Where <b>someName</b> can be any string to uniquely identify the endpoint</p>

<h3><a name="BookComponentAppendix-SimpleExample"></a>Simple Example</h3>

<p>Here's a simple example of MockEndpoint in use. First the endpoint is resolved on the context. Then we set an expectation, then after the test has run we assert our expectations are met.</p>

<div class="code"><div class="codeContent">
<pre class="code-java">MockEndpoint resultEndpoint = context.resolveEndpoint(<span class="code-quote">"mock:foo"</span>, MockEndpoint.class);

resultEndpoint.expectedMessageCount(2);

<span class="code-comment">// send some messages
</span>...

<span class="code-comment">// now lets <span class="code-keyword">assert</span> that the mock:foo endpoint received 2 messages
</span>resultEndpoint.assertIsSatisfied();</pre>
</div></div>

<p>You typically always call the <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#assertIsSatisfied()" title="Visit page outside Confluence" rel="nofollow">assertIsSatisfied() method<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> to test that the expectations were met after running a test.</p>

<h3><a name="BookComponentAppendix-Settingexpectations"></a>Setting expectations</h3>

<p>You can see from the javadoc of <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html" title="Visit page outside Confluence" rel="nofollow">MockEndpoint<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> the various helper methods you can use to set expectations. The main methods available are as follows </p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Method </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectedMessageCount(int)" title="Visit page outside Confluence" rel="nofollow">expectedMessageCount(int)<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> to define the expected message count on the endpoint </td>
</tr>
<tr>
<td class='confluenceTd'> <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectedMinimumMessageCount(int)" title="Visit page outside Confluence" rel="nofollow">expectedMinimumMessageCount(int)<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> to define the minimum number of expected messages on the endpoint </td>
</tr>
<tr>
<td class='confluenceTd'> <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectedBodiesReceived(java.lang.Object...)" title="Visit page outside Confluence" rel="nofollow">expectedBodiesReceived(...)<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> to define the expected bodies that should be received (in order) </td>
</tr>
<tr>
<td class='confluenceTd'> <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectsAscending(org.apache.camel.Expression)" title="Visit page outside Confluence" rel="nofollow">expectsAscending(Expression)<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> to add an expectation that messages are received in order using the given <a href="/confluence/display/CAMEL/Expression" title="Expression">Expression</a> to compare messages </td>
</tr>
<tr>
<td class='confluenceTd'> <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectsDescending(org.apache.camel.Expression)" title="Visit page outside Confluence" rel="nofollow">expectsDescending(Expression)<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> to add an expectation that messages are received in order using the given <a href="/confluence/display/CAMEL/Expression" title="Expression">Expression</a> to compare messages </td>
</tr>
<tr>
<td class='confluenceTd'> <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectsNoDuplicates(org.apache.camel.Expression)" title="Visit page outside Confluence" rel="nofollow">expectsNoDuplicates(Expression)<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </td>
<td class='confluenceTd'> to add an expectation that no duplicate messages are received; using an <a href="/confluence/display/CAMEL/Expression" title="Expression">Expression</a> to calculate a unique identifier for each message. This could be something like the JMSMessageID if using JMS, or some unique reference number within the message. </td>
</tr>
</tbody></table>

<p>Here's another example</p>

<div class="code"><div class="codeContent">
<pre class="code-java">resultEndpoint.expectedBodiesReceived(<span class="code-quote">"firstMessageBody"</span>, <span class="code-quote">"secondMessageBody"</span>, <span class="code-quote">"thirdMessageBody"</span>);</pre>
</div></div>

<h4><a name="BookComponentAppendix-Addingexpectationstospecificmessages"></a>Adding expectations to specific messages</h4>

<p>In addition you can use the <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#message(int)" title="Visit page outside Confluence" rel="nofollow">message(int messageIndex)<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> method to add assertions about a specific message that is received.</p>

<p>For example to add expectations of the headers or body of the first message (using zero based indexing like java.util.List), you can use this code</p>

<div class="code"><div class="codeContent">
<pre class="code-java">resultEndpoint.message(0).header(<span class="code-quote">"foo"</span>).isEqualTo(<span class="code-quote">"bar"</span>);</pre>
</div></div>


<p>There are some examples of the Mock endpoint in use in the <span class="nobr"><a href="http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/" title="Visit page outside Confluence" rel="nofollow">camel-core processor tests<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>.</p>

<h3><a name="BookComponentAppendix-ASpringExample"></a>A Spring Example</h3>

<p>First here's the <span class="nobr"><a href="http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/mock/spring.xml" title="Visit page outside Confluence" rel="nofollow">spring.xml file<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></p>

<div class="code"><div class="codeContent">
<pre class="code-xml"><span class="code-tag">&lt;camelContext xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>
  <span class="code-tag">&lt;route&gt;</span>
    <span class="code-tag">&lt;from uri=<span class="code-quote">"file:src/test/data?noop=true"</span>/&gt;</span>
    <span class="code-tag">&lt;filter&gt;</span>
      <span class="code-tag">&lt;xpath&gt;</span>/person/city = 'London'<span class="code-tag">&lt;/xpath&gt;</span>
      <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:matched"</span>/&gt;</span>
    <span class="code-tag">&lt;/filter&gt;</span>
  <span class="code-tag">&lt;/route&gt;</span>
<span class="code-tag">&lt;/camelContext&gt;</span>

<span class="code-tag">&lt;bean id=<span class="code-quote">"myBean"</span> class=<span class="code-quote">"org.apache.camel.spring.mock.MyAssertions"</span> scope=<span class="code-quote">"singleton"</span>/&gt;</span></pre>
</div></div>

<p>As you can see it defines a simple routing rule which consumes messages from the local <span class="nobr"><a href="http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/data/" title="Visit page outside Confluence" rel="nofollow">src/test/data directory<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. The <b>noop</b> flag just means not to delete or move the file after its been processed.</p>

<p>Also note we instantiate a bean called <b>myBean</b>, here is the <span class="nobr"><a href="http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/mock/MyAssertions.java" title="Visit page outside Confluence" rel="nofollow">source of the MyAssertions bean<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. </p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">public</span> class MyAssertions <span class="code-keyword">implements</span> InitializingBean {
    @EndpointInject(uri = <span class="code-quote">"mock:matched"</span>)
    <span class="code-keyword">private</span> MockEndpoint matched;

    @EndpointInject(uri = <span class="code-quote">"mock:notMatched"</span>)
    <span class="code-keyword">private</span> MockEndpoint notMatched;

    <span class="code-keyword">public</span> void afterPropertiesSet() <span class="code-keyword">throws</span> Exception {
        <span class="code-comment">// lets add some expectations
</span>        matched.expectedMessageCount(1);
        notMatched.expectedMessageCount(0);
    }

    <span class="code-keyword">public</span> void assertEndpointsValid() <span class="code-keyword">throws</span> Exception {
        <span class="code-comment">// now lets perform some assertions that the test worked as we expect
</span>        Assert.assertNotNull(<span class="code-quote">"Should have a matched endpoint"</span>, matched);
        Assert.assertNotNull(<span class="code-quote">"Should have a notMatched endpoint"</span>, notMatched);
        MockEndpoint.assertIsSatisfied(matched, notMatched);
    }
}</pre>
</div></div>

<p>The bean is injected with a bunch of Mock endpoints using the <a href="/confluence/display/CAMEL/Bean+Integration" title="Bean Integration">@EndpointInject annotation</a>, it then sets a bunch of expectations on startup (using Spring's InitializingBean interface and afterPropertiesSet() method) before the CamelContext starts up. </p>

<p>Then in our test case (which could be JUnit or TesNG) we lookup <b>myBean</b> in Spring (or have it injected into our test) and then invoke the <b>assertEndpointsValid()</b> method on it to verify that the mock endpoints have their assertions met. You could then inspect the message exchanges that were delivered to any of the endpoints using the <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#getReceivedExchanges()" title="Visit page outside Confluence" rel="nofollow">getReceivedExchanges()<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> method on the Mock endpoint and perform further assertions or debug logging.</p>

<p>Here is the <span class="nobr"><a href="http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/mock/BeanMockTest.java" title="Visit page outside Confluence" rel="nofollow">actual JUnit test case we use<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>.</p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<ul>
	<li><a href="/confluence/display/CAMEL/Spring+Testing" title="Spring Testing">Spring Testing</a></li>
</ul>

<h2><a name="BookComponentAppendix-MSVComponent"></a>MSV Component</h2>

<p>The MSV component performs XML validation of the message body using the <span class="nobr"><a href="https://msv.dev.java.net/" title="Visit page outside Confluence" rel="nofollow">MSV Library<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> using any of the XML schema languages supported such as <span class="nobr"><a href="http://www.w3.org/XML/Schema" title="Visit page outside Confluence" rel="nofollow">XML Schema<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> or <span class="nobr"><a href="http://relaxng.org/" title="Visit page outside Confluence" rel="nofollow">RelaxNG XML Syntax<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. </p>

<p>Note that the <a href="/confluence/display/CAMEL/Jing" title="Jing">Jing</a> component also supports <span class="nobr"><a href="http://relaxng.org/compact-tutorial-20030326.html" title="Visit page outside Confluence" rel="nofollow">RelaxNG Compact Syntax<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">msv:someLocalOrRemoteResource</pre>
</div></div>

<p>Where <b>someLocalOrRemoteResource</b> is some URL to a local resource on the classpath or a full URL to a remote resource or resource on the file system. For example</p>

<ul>
	<li>msv:org/foo/bar.rng</li>
	<li>msv:<span class="nobr"><a href="file:../foo/bar.rng" title="Visit page outside Confluence" rel="nofollow">file:../foo/bar.rng<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
	<li>msv:<span class="nobr"><a href="http://acme.com/cheese.rng" title="Visit page outside Confluence" rel="nofollow">http://acme.com/cheese.rng<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
</ul>



<h3><a name="BookComponentAppendix-Example"></a>Example</h3>

<p>The following <span class="nobr"><a href="http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-msv/src/test/resources/org/apache/camel/component/validator/msv/camelContext.xml" title="Visit page outside Confluence" rel="nofollow">example<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> shows how to configure a route from endpoint <b>direct:start</b> which then goes to one of two endpoints, either <b>mock:valid</b> or <b>mock:invalid</b> based on whether or not the XML matches the given <span class="nobr"><a href="http://relaxng.org/" title="Visit page outside Confluence" rel="nofollow">RelaxNG XML Schema<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> (which is supplied on the classpath).</p>

<div class="code"><div class="codeContent">
<pre class="code-xml"><span class="code-tag">&lt;camelContext xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>
  <span class="code-tag">&lt;route&gt;</span>
    <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:start"</span>/&gt;</span>
    <span class="code-tag">&lt;try&gt;</span>
      <span class="code-tag">&lt;to uri=<span class="code-quote">"msv:org/apache/camel/component/validator/msv/schema.rng"</span>/&gt;</span>
      <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:valid"</span>/&gt;</span>

      <span class="code-tag">&lt;catch&gt;</span>
        <span class="code-tag">&lt;exception&gt;</span>org.apache.camel.ValidationException<span class="code-tag">&lt;/exception&gt;</span>
        <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:invalid"</span>/&gt;</span>
      <span class="code-tag">&lt;/catch&gt;</span>
    <span class="code-tag">&lt;/try&gt;</span>
  <span class="code-tag">&lt;/route&gt;</span>
<span class="code-tag">&lt;/camelContext&gt;</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-PojoComponent"></a>Pojo Component</h2>

<p>The <b>pojo:</b> component is now just an alias for the <a href="/confluence/display/CAMEL/Bean" title="Bean">Bean</a> component.</p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-QuartzComponent"></a>Quartz Component</h2>

<p>The <b>quartz:</b> component provides a scheduled delivery of messages using the <span class="nobr"><a href="http://www.opensymphony.com/quartz/" title="Visit page outside Confluence" rel="nofollow">Quartz scheduler<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. <br/>
Each endpoint represents a different timer (in Quartz terms, a Trigger and JobDetail).</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">quartz:<span class="code-comment">//timerName?parameters
</span>quartz:<span class="code-comment">//groupName/timerName?parameters
</span>quartz:<span class="code-comment">//groupName/timerName/cronExpression</span></pre>
</div></div>

<p>You can configure the Trigger and JobDetail using the parameters</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Property </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> trigger.repeatCount </td>
<td class='confluenceTd'> How many times should the timer repeat for? </td>
</tr>
<tr>
<td class='confluenceTd'> trigger.repeatInterval </td>
<td class='confluenceTd'> The amount of time in milliseconds between repeated triggers </td>
</tr>
<tr>
<td class='confluenceTd'> job.name </td>
<td class='confluenceTd'> Sets the name of the job </td>
</tr>
</tbody></table>

<p>For example the following routing rule will fire 2 timer events to the endpoint <b>mock:results</b></p>

<div class="code"><div class="codeContent">
<pre class="code-xml">from(<span class="code-quote">"quartz://myGroup/myTimerName?trigger.repeatInterval=2&amp;trigger.repeatCount=1"</span>).to(<span class="code-quote">"mock:result"</span>);</pre>
</div></div>

<h3><a name="BookComponentAppendix-UsingCronTriggers"></a>Using Cron Triggers</h3>

<p>Quartz supports <span class="nobr"><a href="http://www.opensymphony.com/quartz/api/org/quartz/CronTrigger.html" title="Visit page outside Confluence" rel="nofollow">Cron-like expressions<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> for specifying timers in a handy format. You can use these expressions in the URI; though to preserve valid URI encoding we allow / to be used instead of spaces and $ to be used instead of ?.</p>

<p>For example the following will fire a message at 12pm (noon) every day</p>

<div class="code"><div class="codeContent">
<pre class="code-xml">from(<span class="code-quote">"quartz://myGroup/myTimerName/0/0/12/*/*/$"</span>).to(<span class="code-quote">"activemq:Totally.Rocks"</span>);</pre>
</div></div>

<p>which is equivalent to using the cron expression</p>

<div class="code"><div class="codeContent">
<pre class="code-java">0 0 12 * * ?</pre>
</div></div>

<p>The following table shows the URI character encodings we use to preserve valid URI syntax</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'>URI Character</th>
<th class='confluenceTh'>Cron character</th>
</tr>
<tr>
<td class='confluenceTd'> '/' </td>
<td class='confluenceTd'> ' ' </td>
</tr>
<tr>
<td class='confluenceTd'> '$' </td>
<td class='confluenceTd'> '?' </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<ul>
	<li><a href="/confluence/display/CAMEL/Timer" title="Timer">Timer</a></li>
</ul>


<h2><a name="BookComponentAppendix-QueueComponent"></a>Queue Component</h2>

<table cellpadding='5' width='85%' cellspacing='8px' class='warningMacro' border="0" align='center'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/confluence/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b class="strong">Deprecated</b><br />
<p>To avoid confusion with JMS queues, this component is now deprecated in 1.1 onwards. Please use the <a href="/confluence/display/CAMEL/SEDA" title="SEDA">SEDA</a> component instead</p></td></tr></table>

<p>The <b>queue:</b> component provides asynchronous <span class="nobr"><a href="http://www.eecs.harvard.edu/~mdw/proj/seda/" title="Visit page outside Confluence" rel="nofollow">SEDA<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> behaviour so that messages are exchanged on a <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/BlockingQueue.html" title="Visit page outside Confluence" rel="nofollow">BlockingQueue<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> and consumers are invoked in a seperate thread pool to the producer.</p>

<p>Note that queues are only visible within a single <a href="/confluence/display/CAMEL/CamelContext" title="CamelContext">CamelContext</a>. If you want to communicate across CamelContext instances such as to communicate across web applications, see the <a href="/confluence/display/CAMEL/VM" title="VM">VM</a> component.</p>

<p>Note also that this component has nothing to do with <a href="/confluence/display/CAMEL/JMS" title="JMS">JMS</a>, if you want a distributed SEA then try using either <a href="/confluence/display/CAMEL/JMS" title="JMS">JMS</a> or <a href="/confluence/display/CAMEL/ActiveMQ" title="ActiveMQ">ActiveMQ</a> or even <a href="/confluence/display/CAMEL/MINA" title="MINA">MINA</a></p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">queue:someName</pre>
</div></div>

<p>Where <b>someName</b> can be any string to uniquely identify the endpoint within the current <a href="/confluence/display/CAMEL/CamelContext" title="CamelContext">CamelContext</a></p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-RefComponent"></a>Ref Component</h2>

<p>The <b>ref:</b> component is used for lookup of existing endpoints bound in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">ref:someName</pre>
</div></div>

<p>Where <b>someName</b> can be any string which is used to lookup the endpoint in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>.</p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-RMIComponent"></a>RMI Component</h2>

<p>The <b>rmi:</b> component bind the <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/pojo/PojoExchange.html" title="Visit page outside Confluence" rel="nofollow">PojoExchanges<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> to the RMI protocol (JRMP).</p>

<p>Since this binding is just using RMI, normal RMI rules still apply in regards to what the methods can be used over it.  This component only supports <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/pojo/PojoExchange.html" title="Visit page outside Confluence" rel="nofollow">PojoExchanges<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> that carry a method invocation that is part of an interface that extends the <span class="nobr"><a href="http://java.sun.com/j2se/1.3/docs/api/java/rmi/Remote.html" title="Visit page outside Confluence" rel="nofollow">Remote<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> interface.  All parameters in the method should be either <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html" title="Visit page outside Confluence" rel="nofollow">Serializable<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> or Remote objects too.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">rmi:<span class="code-comment">//rmi-regisitry-host:rmi-registry-port/registry-path</span></pre>
</div></div>

<p>For example:</p>

<div class="code"><div class="codeContent">
<pre class="code-java">rmi:<span class="code-comment">//localhost:1099/path/to/service</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-Using"></a>Using</h3>

<p>To call out to an existing RMI service registered in an RMI registry, create a Route similar to:</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"pojo:foo"</span>).to(<span class="code-quote">"rmi:<span class="code-comment">//localhost:1099/foo"</span>);</span></pre>
</div></div>

<p>To bind an existing camel processor or service in an RMI registry, create a Route like:</p>

<div class="code"><div class="codeContent">
<pre class="code-java">RmiEndpoint endpoint= (RmiEndpoint) endpoint(<span class="code-quote">"rmi:<span class="code-comment">//localhost:1099/bar"</span>);
</span>endpoint.setRemoteInterfaces(ISay.class);
from(endpoint).to(<span class="code-quote">"pojo:bar"</span>);</pre>
</div></div>

<p>Notice that when binding an inbound RMI endpoint, the Remote interfaces exposed must be specified.</p>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> method </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> As of 1.3 or later you can set the name of the method to invoke </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-SEDAComponent"></a>SEDA Component</h2>

<p>The <b>seda:</b> component provides asynchronous <span class="nobr"><a href="http://www.eecs.harvard.edu/~mdw/proj/seda/" title="Visit page outside Confluence" rel="nofollow">SEDA<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> behaviour so that messages are exchanged on a <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/BlockingQueue.html" title="Visit page outside Confluence" rel="nofollow">BlockingQueue<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> and consumers are invoked in a seperate thread to the producer.  Be aware that adding a thread pool to a seda<br/>
endpoint by doing something like: from("seda:stageName").thread(5).process(...) can wind up with two BlockQueues.  One from seda endpoint and one from the workqueue of the thread pool which may not be what you want.  Instead, you might want to consider configuring a direct endpoint with a thread pool which can process messages both synchronously and asynchronously.  For example, from(direct:stageName").thread(5).process(..). </p>


<p>Note that queues are only visible within a single <a href="/confluence/display/CAMEL/CamelContext" title="CamelContext">CamelContext</a>. If you want to communicate across CamelContext instances such as to communicate across web applications, see the <a href="/confluence/display/CAMEL/VM" title="VM">VM</a> component.</p>

<p>This component does not implement any kind of persistence or recovery if the VM termininates while messages are yet to be processed. If you need persistence, reliability or distributed SEDA then try using either <a href="/confluence/display/CAMEL/JMS" title="JMS">JMS</a> or <a href="/confluence/display/CAMEL/ActiveMQ" title="ActiveMQ">ActiveMQ</a></p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">seda:someName</pre>
</div></div>

<p>Where <b>someName</b> can be any string to uniquely identify the endpoint within the current <a href="/confluence/display/CAMEL/CamelContext" title="CamelContext">CamelContext</a></p>

<h3><a name="BookComponentAppendix-URIOptions"></a>URI Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> size </td>
<td class='confluenceTd'> The maximum size of the SEDA queue </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-SpringIntegrationComponent"></a>Spring Integration Component</h2>

<p>The <b>spring-integration:</b> component provides a bridge for Camel components to talk to <span class="nobr"><a href="http://activemq.apache.org/camel/springintegration.html" title="Visit page outside Confluence" rel="nofollow">spring integration endpoints<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">spring-integration:defaultChannelName[?options]</pre>
</div></div>
<p>Where <b>defaultChannelName</b> represents the default channel name which is used by the Spring Integration Spring context. It will equal to the inputChannel name for the Spring Integration consumer and the outputChannel name for the Spring Integration provider.</p>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Description </th>
<th class='confluenceTh'> Example </th>
<th class='confluenceTh'> Required </th>
<th class='confluenceTh'> default value </th>
</tr>
<tr>
<td class='confluenceTd'> inputChannel </td>
<td class='confluenceTd'> The spring integration input channel name this endpoint wants to consume from that is defined in the spring context </td>
<td class='confluenceTd'> inputChannel=requestChannel </td>
<td class='confluenceTd'> No </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> outputChannel </td>
<td class='confluenceTd'> The spring integration output channel name to send message to the spring integration context  </td>
<td class='confluenceTd'> outputChannel=replyChannel </td>
<td class='confluenceTd'> No </td>
<td class='confluenceTd'>&nbsp;</td>
</tr>
<tr>
<td class='confluenceTd'> inOut </td>
<td class='confluenceTd'> The exchange pattern that spring integration endpoint should use </td>
<td class='confluenceTd'> inOut=true</td>
<td class='confluenceTd'> No </td>
<td class='confluenceTd'>inOnly for the spring integration consumer and outOnly for the spring integration provider </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Usage"></a>Usage</h3>

<p>Spring Integration component is a bridge which connects Spring Integration endpoints through the Spring integration's input and output channels with the Camel endpoints. In this way, we can send out the Camel message to Spring Integration endpoints or receive the message from Spring Integration endpoint in Camel routing context.</p>

<h3><a name="BookComponentAppendix-Examples"></a>Examples</h3>

<h4><a name="BookComponentAppendix-UsingtheSpringIntegrationEndpoint"></a>Using the Spring Integration Endpoint</h4>
<p>You could setup the Spring Integration Endpoint by using the URI </p>

<div class="code"><div class="codeContent">
<pre class="code-xml">&lt;beans:beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/integration"</span>
	<span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
	<span class="code-keyword">xmlns:beans</span>=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
	xsi:schemaLocation="http://www.springframework.org/schema/beans
			http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
			http://www.springframework.org/schema/integration
			http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
			http://activemq.apache.org/camel/schema/spring
			http://activemq.apache.org/camel/schema/spring/camel-spring.xsd"&gt;

	<span class="code-tag">&lt;message-bus auto-create-channels=<span class="code-quote">"true"</span>/&gt;</span>

	&lt;handler-endpoint input-channel=<span class="code-quote">"inputChannel"</span>
	          output-channel=<span class="code-quote">"outputChannel"</span>
	          handler=<span class="code-quote">"helloService"</span>
	          method=<span class="code-quote">"sayHello"</span>/&gt;

	<span class="code-tag">&lt;beans:bean id=<span class="code-quote">"helloService"</span> class=<span class="code-quote">"org.apache.camel.component.spring.integration.HelloWorldService"</span>/&gt;</span>
    <span class="code-tag">&lt;camelContext id=<span class="code-quote">"camel"</span> xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>
      <span class="code-tag">&lt;route&gt;</span>
        <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:start"</span>/&gt;</span>
        <span class="code-tag"><span class="code-comment">&lt;!-- Using the &amp;amp; as the separator of &amp; --&gt;</span></span>
        <span class="code-tag">&lt;to uri=<span class="code-quote">"spring-integration:inputChannel?inOut=true&amp;amp;inputChannel=outputChannel"</span>/&gt;</span>
      <span class="code-tag">&lt;/route&gt;</span>
    <span class="code-tag">&lt;/camelContext&gt;</span></pre>
</div></div>

<div class="code"><div class="codeContent">
<pre class="code-xml"><span class="code-tag">&lt;message-bus auto-create-channels=<span class="code-quote">"true"</span>/&gt;</span>

   <span class="code-tag">&lt;channel id=<span class="code-quote">"requestChannel"</span>/&gt;</span>
   <span class="code-tag">&lt;channel id=<span class="code-quote">"responseChannel"</span>/&gt;</span>

   <span class="code-tag">&lt;beans:bean id=<span class="code-quote">"myProcessor"</span> class=<span class="code-quote">"org.apache.camel.component.spring.integration.MyProcessor"</span>/&gt;</span>

   <span class="code-tag">&lt;camelContext id=<span class="code-quote">"camel"</span> xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>
     <span class="code-tag">&lt;route&gt;</span>
       <span class="code-tag"><span class="code-comment">&lt;!-- Using the &amp;amp; as the separator of &amp; --&gt;</span></span>
       <span class="code-tag">&lt;from uri=<span class="code-quote">"spring-integration://requestChannel?outputChannel=responseChannel&amp;amp;inOut=true"</span>/&gt;</span>
       <span class="code-tag">&lt;process ref=<span class="code-quote">"myProcessor"</span>/&gt;</span>
     <span class="code-tag">&lt;/route&gt;</span>
   <span class="code-tag">&lt;/camelContext&gt;</span></pre>
</div></div>

<p>or by the Spring Integration Channel name</p>

<div class="code"><div class="codeContent">
<pre class="code-xml">&lt;beans:beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/integration"</span>
	<span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
	<span class="code-keyword">xmlns:beans</span>=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
	xsi:schemaLocation="http://www.springframework.org/schema/beans
			http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
			http://www.springframework.org/schema/integration
			http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
			http://activemq.apache.org/camel/schema/spring
			http://activemq.apache.org/camel/schema/spring/camel-spring.xsd"&gt;
	<span class="code-tag">&lt;message-bus auto-create-channels=<span class="code-quote">"true"</span>/&gt;</span>

    <span class="code-tag">&lt;channel id=<span class="code-quote">"outputChannel"</span>/&gt;</span>

    <span class="code-tag">&lt;camelContext id=<span class="code-quote">"camel"</span> xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>
      <span class="code-tag">&lt;route&gt;</span>
        <span class="code-tag"><span class="code-comment">&lt;!-- camel will create a spring integration endpoint automatically --&gt;</span></span>
        <span class="code-tag">&lt;from uri=<span class="code-quote">"outputChannel"</span>/&gt;</span>
        <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:result"</span>/&gt;</span>
      <span class="code-tag">&lt;/route&gt;</span>
    <span class="code-tag">&lt;/camelContext&gt;</span></pre>
</div></div>

<h4><a name="BookComponentAppendix-TheSourceandTargetadapter"></a>The Source and Target adapter</h4>

<p>Spring Integartion also provides the Spring Integration's Source and Target adapters which could route the message from the Spring Integration channel to a camel context endpoint or from a camel context endpoint to a Spring Integration Channel.</p>

<p>Here is the name spaces header</p>

<div class="code"><div class="codeContent">
<pre class="code-xml">&lt;beans:beans xmlns=<span class="code-quote">"http://www.springframework.org/schema/integration"</span>
       <span class="code-keyword">xmlns:beans</span>=<span class="code-quote">"http://www.springframework.org/schema/beans"</span>
       <span class="code-keyword">xmlns:xsi</span>=<span class="code-quote">"http://www.w3.org/2001/XMLSchema-instance"</span>
       <span class="code-keyword">xmlns:camel-si</span>=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring/integration"</span>
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/integration
	   http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
       http://activemq.apache.org/camel/schema/spring/integration
       http://activemq.apache.org/camel/schema/spring/integration/camel-spring-integration.xsd
       http://activemq.apache.org/camel/schema/spring
       http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
    "&gt;</pre>
</div></div>

<p>Now you could bind your source or target to camel context endpoint</p>

<div class="code"><div class="codeContent">
<pre class="code-xml"><span class="code-tag"><span class="code-comment">&lt;!-- Create the camel context here --&gt;</span></span>
<span class="code-tag">&lt;camelContext id=<span class="code-quote">"camelTargetContext"</span> xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>
    <span class="code-tag">&lt;route&gt;</span>
        <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:EndpointA"</span> /&gt;</span>
        <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:result"</span> /&gt;</span>
    <span class="code-tag">&lt;/route&gt;</span>
    <span class="code-tag">&lt;route&gt;</span>
        <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:EndpointC"</span>/&gt;</span>
        <span class="code-tag">&lt;process ref=<span class="code-quote">"myProcessor"</span>/&gt;</span>
      <span class="code-tag">&lt;/route&gt;</span>
<span class="code-tag">&lt;/camelContext&gt;</span>

<span class="code-tag"><span class="code-comment">&lt;!-- We can bind the camelTarget to the camel context's endpoint by specifying the camelEndpointUri attribute --&gt;</span></span>
<span class="code-tag">&lt;camel-si:camelTarget id=<span class="code-quote">"camelTargetA"</span> camelEndpointUri=<span class="code-quote">"direct:EndpointA"</span> requestChannel=<span class="code-quote">"channelA"</span> expectReply=<span class="code-quote">"false"</span>&gt;</span>
    <span class="code-tag">&lt;camel-si:camelContextRef&gt;</span>camelTargetContext<span class="code-tag">&lt;/camel-si:camelContextRef&gt;</span>
<span class="code-tag">&lt;/camel-si:camelTarget&gt;</span>

<span class="code-tag">&lt;camel-si:camelTarget id=<span class="code-quote">"camelTargetB"</span> camelEndpointUri=<span class="code-quote">"direct:EndpointC"</span> requestChannel=<span class="code-quote">"channelB"</span> replyChannel=<span class="code-quote">"channelC"</span> expectReply=<span class="code-quote">"true"</span>&gt;</span>
    <span class="code-tag">&lt;camel-si:camelContextRef&gt;</span>camelTargetContext<span class="code-tag">&lt;/camel-si:camelContextRef&gt;</span>
<span class="code-tag">&lt;/camel-si:camelTarget&gt;</span>

<span class="code-tag">&lt;beans:bean id=<span class="code-quote">"myProcessor"</span> class=<span class="code-quote">"org.apache.camel.component.spring.integration.MyProcessor"</span>/&gt;</span></pre>
</div></div>

<div class="code"><div class="codeContent">
<pre class="code-xml"><span class="code-tag">&lt;camelContext id=<span class="code-quote">"camelSourceContext"</span> xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>
    <span class="code-tag">&lt;route&gt;</span>
        <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:OneWay"</span>/&gt;</span>
        <span class="code-tag">&lt;to uri=<span class="code-quote">"direct:EndpointB"</span> /&gt;</span>
    <span class="code-tag">&lt;/route&gt;</span>
    <span class="code-tag">&lt;route&gt;</span>
    	   <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:TwoWay"</span>/&gt;</span>
        <span class="code-tag">&lt;to uri=<span class="code-quote">"direct:EndpointC"</span> /&gt;</span>
    <span class="code-tag">&lt;/route&gt;</span>
<span class="code-tag">&lt;/camelContext&gt;</span>

<span class="code-tag"><span class="code-comment">&lt;!-- camelSource will redirect the message coming for direct:EndpointB to the spring requestChannel channelA --&gt;</span></span>

<span class="code-tag">&lt;camel-si:camelSource id=<span class="code-quote">"camelSourceA"</span> camelEndpointUri=<span class="code-quote">"direct:EndpointB"</span> requestChannel=<span class="code-quote">"channelA"</span> expectReply=<span class="code-quote">"false"</span>&gt;</span>
    <span class="code-tag">&lt;camel-si:camelContextRef&gt;</span>camelSourceContext<span class="code-tag">&lt;/camel-si:camelContextRef&gt;</span>
<span class="code-tag">&lt;/camel-si:camelSource&gt;</span>

&lt;!-- camelSource will redirect the message coming for direct:EndpointC to the spring requestChannel channelB
 then it will pull the response from channelC and put the response message back to direct:EndpointC --&gt;

<span class="code-tag">&lt;camel-si:camelSource id=<span class="code-quote">"camelSourceB"</span> camelEndpointUri=<span class="code-quote">"direct:EndpointC"</span> requestChannel=<span class="code-quote">"channelB"</span> replyChannel=<span class="code-quote">"channelC"</span> expectReply=<span class="code-quote">"true"</span>&gt;</span>
    <span class="code-tag">&lt;camel-si:camelContextRef&gt;</span>camelSourceContext<span class="code-tag">&lt;/camel-si:camelContextRef&gt;</span>
<span class="code-tag">&lt;/camel-si:camelSource&gt;</span></pre>
</div></div>


<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-StreamComponent"></a>Stream Component</h2>

<p>The <b>stream:</b> component provides access to the System.in, System.out and System.err streams together with allowing streaming of output to a file.<br/>
Notice that some of the stream types has been @deprecated (file and url). These types are supported by their respective components.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">stream:in
stream:out
stream:err
stream:file?file=/foo/bar.txt  (@deprecated)
stream:url (@deprecated) 
stream:header</pre>
</div></div>

<p>If the <b>stream:header</b> option is specified then the <b>stream</b> header is used to find the stream to write to. This option is only available for StreamProducer.</p>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> file </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> When using the <b>stream:file</b> notation this specifies the file name to stream to/from. @deprecated. </td>
</tr>
<tr>
<td class='confluenceTd'> delay </td>
<td class='confluenceTd'> 0 </td>
<td class='confluenceTd'> Initial delay in millis before consuming or producing the stream. </td>
</tr>
<tr>
<td class='confluenceTd'> encoding </td>
<td class='confluenceTd'> JVM Default </td>
<td class='confluenceTd'>  As of 1.4 or later you can configure the encoding (is a <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/nio/charset/Charset.html" title="Visit page outside Confluence" rel="nofollow">charset name<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>) to use text based streams (eg. message body is a String object). If not provided Camel will use the <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/nio/charset/Charset.html#defaultCharset()" title="Visit page outside Confluence" rel="nofollow">JVM default Charset<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Messagecontent"></a>Message content</h3>

<p>The <b>stream:</b> component supports either String or byte[] for writing to streams. Just add to the <tt>message.in.body</tt> either a Stirng or byte[] content.<br/>
The special <b>stream:header</b> URI is used for custom output streams. Just add a <tt>java.io.OutputStream</tt> to <tt>message.in.header</tt> in the key <tt>header</tt>.<br/>
See samples for an example.</p>

<h3><a name="BookComponentAppendix-Samples"></a>Samples</h3>

<p>In this sample we output to System.out the content from the message when its put on the direct:in queue.</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">public</span> void testStringContent() <span class="code-keyword">throws</span> Exception {
    template.sendBody(<span class="code-quote">"direct:in"</span>, <span class="code-quote">"Hello Text World\n"</span>);
}

<span class="code-keyword">public</span> void testBinaryContent() {
    template.sendBody(<span class="code-quote">"direct:in"</span>, <span class="code-quote">"Hello Bytes World\n"</span>.getBytes());
}

<span class="code-keyword">protected</span> RouteBuilder createRouteBuilder() {
    <span class="code-keyword">return</span> <span class="code-keyword">new</span> RouteBuilder() {
        <span class="code-keyword">public</span> void configure() {
            from(<span class="code-quote">"direct:in"</span>).to(<span class="code-quote">"stream:out"</span>);
        }
    };
}</pre>
</div></div>

<p>This sample demonstrates how the header type can be used to determine which stream to use. In the sample we use our own output stream (MyOutputStream).</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">private</span> OutputStream mystream = <span class="code-keyword">new</span> MyOutputStream();
<span class="code-keyword">private</span> <span class="code-object">StringBuffer</span> sb = <span class="code-keyword">new</span> <span class="code-object">StringBuffer</span>();

<span class="code-keyword">public</span> void testStringContent() {
    template.sendBody(<span class="code-quote">"direct:in"</span>, <span class="code-quote">"Hello"</span>);
    <span class="code-comment">// StreamProducer appends \n in text mode
</span>    assertEquals(<span class="code-quote">"Hello\n"</span>, sb.toString());
}

<span class="code-keyword">public</span> void testBinaryContent() {
    template.sendBody(<span class="code-quote">"direct:in"</span>, <span class="code-quote">"Hello"</span>.getBytes());
    <span class="code-comment">// StreamProducer is in binary mode so no \n is appended
</span>    assertEquals(<span class="code-quote">"Hello"</span>, sb.toString());
}

<span class="code-keyword">protected</span> RouteBuilder createRouteBuilder() {
    <span class="code-keyword">return</span> <span class="code-keyword">new</span> RouteBuilder() {
        <span class="code-keyword">public</span> void configure() {
            from(<span class="code-quote">"direct:in"</span>).setHeader(<span class="code-quote">"stream"</span>, constant(mystream)).
                to(<span class="code-quote">"stream:header"</span>);
        }
    };
}

<span class="code-keyword">private</span> class MyOutputStream <span class="code-keyword">extends</span> OutputStream {

    <span class="code-keyword">public</span> void write(<span class="code-object">int</span> b) <span class="code-keyword">throws</span> IOException {
        <span class="code-object">char</span> c = (<span class="code-object">char</span>)b;
        sb.append((<span class="code-object">char</span>)b);
    }
}</pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-StringTemplate"></a>String Template</h2>

<p>The <b>string-template:</b> component allows you to process a message using a <span class="nobr"><a href="http://www.stringtemplate.org/" title="Visit page outside Confluence" rel="nofollow">String Template<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. This can be ideal when using <a href="/confluence/display/CAMEL/Templating" title="Templating">Templating</a> to generate responses for requests.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">string-template:templateName</pre>
</div></div>

<p>Where <b>templateName</b> is the classpath-local URI of the template to invoke; or the complete URL of the remote template.</p>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Option </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> contentCache </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> New option in Camel 1.4. Cache for the resource content when its loaded. </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Headers"></a>Headers</h3>
<p>Camel will store a reference to the resource in the message header in the key <tt>org.apache.camel.stringtemplate.resource</tt>. The Resource is an <tt>org.springframework.core.io.Resource</tt> object.</p>

<h3><a name="BookComponentAppendix-Hotreloading"></a>Hot reloading</h3>
<p>The stringtemplate resource is by default hot reloadable for both file and classpath resources (expanded jar). Setting the contentCache=true then Camel will only load the resource once, and thus hot reloading is not possible. This scenario can be used in production usage when the resource never changes.</p>

<h3><a name="BookComponentAppendix-StringTemplateAttributes"></a>StringTemplate Attributes</h3>
<p>Camel will provide exchange information as attributes (just a Map) to the string template. The Exchange is transfered as:</p>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> key </th>
<th class='confluenceTh'> value </th>
</tr>
<tr>
<td class='confluenceTd'> exchange </td>
<td class='confluenceTd'> The Exchange itself </td>
</tr>
<tr>
<td class='confluenceTd'> headers </td>
<td class='confluenceTd'> The headers of the in message </td>
</tr>
<tr>
<td class='confluenceTd'> camelContext </td>
<td class='confluenceTd'> The Camel Context </td>
</tr>
<tr>
<td class='confluenceTd'> request </td>
<td class='confluenceTd'> The in message </td>
</tr>
<tr>
<td class='confluenceTd'> in </td>
<td class='confluenceTd'> The in message </td>
</tr>
<tr>
<td class='confluenceTd'> body </td>
<td class='confluenceTd'> The in message body</td>
</tr>
<tr>
<td class='confluenceTd'> out </td>
<td class='confluenceTd'> The out message (only for InOut message exchange pattern) </td>
</tr>
<tr>
<td class='confluenceTd'> response </td>
<td class='confluenceTd'> The out message (only for InOut message exchange pattern) </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Samples"></a>Samples</h3>

<p>For example you could use something like</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"activemq:My.Queue"</span>).
  to(<span class="code-quote">"string-template:com/acme/MyResponse.tm"</span>);</pre>
</div></div>

<p>To use a string template to formulate a response for a message</p>

<h3><a name="BookComponentAppendix-TheEmailSample"></a>The Email Sample</h3>
<p>In this sample we want to use StringTemplate as templating for an order confirmation email. The email template is laid out in StringTemplate as:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">Dear $headers.lastName$, $headers.firstName$

Thanks <span class="code-keyword">for</span> the order of $headers.item$.

Regards Camel Riders Bookstore
$body$</pre>
</div></div>

<p>And the java code:</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">private</span> Exchange createLetter() {
    Exchange exchange = context.getEndpoint(<span class="code-quote">"direct:a"</span>).createExchange();
    Message msg = exchange.getIn();
    msg.setHeader(<span class="code-quote">"firstName"</span>, <span class="code-quote">"Claus"</span>);
    msg.setHeader(<span class="code-quote">"lastName"</span>, <span class="code-quote">"Ibsen"</span>);
    msg.setHeader(<span class="code-quote">"item"</span>, <span class="code-quote">"Camel in Action"</span>);
    msg.setBody(<span class="code-quote">"PS: Next beer is on me, James"</span>);
    <span class="code-keyword">return</span> exchange;
}

<span class="code-keyword">public</span> void testVelocityLetter() <span class="code-keyword">throws</span> Exception {
    MockEndpoint mock = getMockEndpoint(<span class="code-quote">"mock:result"</span>);
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived(<span class="code-quote">"Dear Ibsen, Claus\n\nThanks <span class="code-keyword">for</span> the order of Camel in Action.\n\nRegards Camel Riders Bookstore\nPS: Next beer is on me, James"</span>);

    template.send(<span class="code-quote">"direct:a"</span>, createLetter());

    mock.assertIsSatisfied();
}

<span class="code-keyword">protected</span> RouteBuilder createRouteBuilder() <span class="code-keyword">throws</span> Exception {
    <span class="code-keyword">return</span> <span class="code-keyword">new</span> RouteBuilder() {
        <span class="code-keyword">public</span> void configure() <span class="code-keyword">throws</span> Exception {
            from(<span class="code-quote">"direct:a"</span>).to(<span class="code-quote">"string-template:org/apache/camel/component/stringtemplate/letter.tm"</span>).to(<span class="code-quote">"mock:result"</span>);
        }
    };
}</pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-TestComponent"></a>Test Component</h2>

Testing of distributed and asynchronous processing is notoriously difficult. The <a href="/confluence/display/CAMEL/Mock" title="Mock">Mock</a>, <a href="/confluence/display/CAMEL/Test" title="Test">Test</a> and <a href="/confluence/display/CAMEL/DataSet" title="DataSet">DataSet</a> endpoints work great with the <a href="/confluence/display/CAMEL/Spring+Testing" title="Spring Testing">Spring Testing</a> framework to simplify your unit and integration testing using <a href="/confluence/display/CAMEL/Enterprise+Integration+Patterns" title="Enterprise Integration Patterns">Enterprise Integration Patterns</a> and Camel's large range of <a href="/confluence/display/CAMEL/Components" title="Components">Components</a> together with the powerful <a href="/confluence/display/CAMEL/Mock" title="Mock">Mock</a> and <a href="/confluence/display/CAMEL/Test" title="Test">Test</a> testing endpoints.

<p>The Test component extends the <a href="/confluence/display/CAMEL/Mock" title="Mock">Mock</a> component to support pulling messages from another endpoint on startup to set the expected message bodies on the underlying <a href="/confluence/display/CAMEL/Mock" title="Mock">Mock</a> endpoint.</p>

<p>i.e. you use the test endpoint in a route and messages arriving on it will be implicitly compared to some expected messages extracted from some other location.</p>

<p>So you can use for example an expected set of message bodies as files. This will then setup a properly configured <a href="/confluence/display/CAMEL/Mock" title="Mock">Mock</a> endpoint which is only valid if the received messages match the number of expected messages and their message payloads are equal.</p>


<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">test:expectedMessagesEndpointUri</pre>
</div></div>

<p>Where <b>expectedMessagesEndpointUri</b> refers to some other <a href="/confluence/display/CAMEL/Component" title="Component">Component</a> URI where the expected message bodies are pulled from before starting the test. </p>

<h3><a name="BookComponentAppendix-Example"></a>Example</h3>

<p>For example you could write a test case as follows</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"seda:someEndpoint"</span>).
  to(<span class="code-quote">"test:file:<span class="code-comment">//data/expectedOutput?noop=<span class="code-keyword">true</span>"</span>);</span></pre>
</div></div>

<p>If your test then invokes the <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#assertIsSatisfied(org.apache.camel.CamelContext)" title="Visit page outside Confluence" rel="nofollow">MockEndpoint.assertIsSatisfied(camelContext) method<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> then your test case will perform the necessary assertions.</p>

<p>Here is a <span class="nobr"><a href="http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/test/TestEndpointTest.java?view=markup" title="Visit page outside Confluence" rel="nofollow">real example test case using Mock and Spring<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> along with its <span class="nobr"><a href="https://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/test/TestEndpointTest-context.xml" title="Visit page outside Confluence" rel="nofollow">Spring XML<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>.</p>

<p>To see how you can set other expectations on the test endpoint, see the <a href="/confluence/display/CAMEL/Mock" title="Mock">Mock</a> component.</p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<ul>
	<li><a href="/confluence/display/CAMEL/Spring+Testing" title="Spring Testing">Spring Testing</a></li>
</ul>

<h2><a name="BookComponentAppendix-TimerComponent"></a>Timer Component</h2>

<p>The <b>timer:</b> component is used to generate message exchanges when a timer fires You can only consume events from this endpoint.  </p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">timer:name?options</pre>
</div></div> 

<p>Where <b>options</b> is a query string that can specify any of the following parameters:</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> name </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> The name of the Timer object which is created and shared across endpoints. So if you use the same name for all your timer endpoints then only one Timer object &amp; thread will be used </td>
</tr>
<tr>
<td class='confluenceTd'> time </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> The date/time that the (first) event should be generated. </td>
</tr>
<tr>
<td class='confluenceTd'> period </td>
<td class='confluenceTd'> -1 </td>
<td class='confluenceTd'> If set to greater than 0, then generate periodic events every period milliseconds </td>
</tr>
<tr>
<td class='confluenceTd'> delay </td>
<td class='confluenceTd'> -1 </td>
<td class='confluenceTd'> The number of milliseconds to wait before the first event is generated.  Should not be used in conjunction with the time parameter. </td>
</tr>
<tr>
<td class='confluenceTd'> fixedRate </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> Events take place at approximately regular intervals, separated by the specified period. </td>
</tr>
<tr>
<td class='confluenceTd'> daemon </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Should the thread associated with the timer endpoint be run as a daemon. </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Using"></a>Using</h3>

<p>To setup a route that generates an event every 60 seconds:</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"timer:<span class="code-comment">//foo?fixedRate=<span class="code-keyword">true</span>&amp;delay=0&amp;period=60000"</span>).to(<span class="code-quote">"bean:myBean?methodName=someMethodName"</span>);</span></pre>
</div></div>

<p>The above route will generate an event then invoke the someMethodName on the bean called myBean in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a> such as JNDI or <a href="/confluence/display/CAMEL/Spring" title="Spring">Spring</a>.</p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<ul>
	<li><a href="/confluence/display/CAMEL/Quartz" title="Quartz">Quartz</a></li>
</ul>


<h2><a name="BookComponentAppendix-ValidationComponent"></a>Validation Component</h2>

<p>The Validation component performs XML validation of the message body using the JAXP Validation API using any of the supported XML schema languages, which defaults to <span class="nobr"><a href="http://www.w3.org/XML/Schema" title="Visit page outside Confluence" rel="nofollow">XML Schema<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> </p>

<p>Note that the <a href="/confluence/display/CAMEL/Jing" title="Jing">Jing</a> component also supports the following schema languages which are useful</p>

<ul>
	<li><span class="nobr"><a href="http://relaxng.org/compact-tutorial-20030326.html" title="Visit page outside Confluence" rel="nofollow">RelaxNG Compact Syntax<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
	<li><span class="nobr"><a href="http://relaxng.org/" title="Visit page outside Confluence" rel="nofollow">RelaxNG XML Syntax<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
</ul>


<p>The <a href="/confluence/display/CAMEL/MSV" title="MSV">MSV</a> component also supports <span class="nobr"><a href="http://relaxng.org/" title="Visit page outside Confluence" rel="nofollow">RelaxNG XML Syntax<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">validator:someLocalOrRemoteResource</pre>
</div></div>

<p>Where <b>someLocalOrRemoteResource</b> is some URL to a local resource on the classpath or a full URL to a remote resource or resource on the file system which contains the XSD to validate against. For example</p>

<ul>
	<li>msv:org/foo/bar.xsd</li>
	<li>msv:<span class="nobr"><a href="file:../foo/bar.xsd" title="Visit page outside Confluence" rel="nofollow">file:../foo/bar.xsd<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
	<li>msv:<span class="nobr"><a href="http://acme.com/cheese.xsd" title="Visit page outside Confluence" rel="nofollow">http://acme.com/cheese.xsd<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></li>
	<li>validator:com/mypackage/myschema.xsd</li>
</ul>


<h3><a name="BookComponentAppendix-Example"></a>Example</h3>

<p>The following <span class="nobr"><a href="http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/validator/camelContext.xml" title="Visit page outside Confluence" rel="nofollow">example<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> shows how to configure a route from endpoint <b>direct:start</b> which then goes to one of two endpoints, either <b>mock:valid</b> or <b>mock:invalid</b> based on whether or not the XML matches the given schema (which is supplied on the classpath).</p>

<div class="code"><div class="codeContent">
<pre class="code-xml"><span class="code-tag">&lt;camelContext xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>
  <span class="code-tag">&lt;route&gt;</span>
    <span class="code-tag">&lt;from uri=<span class="code-quote">"direct:start"</span>/&gt;</span>
    <span class="code-tag">&lt;try&gt;</span>
      <span class="code-tag">&lt;to uri=<span class="code-quote">"validator:org/apache/camel/component/validator/schema.xsd"</span>/&gt;</span>
      <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:valid"</span>/&gt;</span>

      <span class="code-tag">&lt;catch&gt;</span>
        <span class="code-tag">&lt;exception&gt;</span>org.apache.camel.ValidationException<span class="code-tag">&lt;/exception&gt;</span>
        <span class="code-tag">&lt;to uri=<span class="code-quote">"mock:invalid"</span>/&gt;</span>
      <span class="code-tag">&lt;/catch&gt;</span>
    <span class="code-tag">&lt;/try&gt;</span>
  <span class="code-tag">&lt;/route&gt;</span>
<span class="code-tag">&lt;/camelContext&gt;</span></pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-Velocity"></a>Velocity</h2>

<p>The <b>velocity:</b> component allows you to process a message using an <span class="nobr"><a href="http://velocity.apache.org/" title="Visit page outside Confluence" rel="nofollow">Apache Velocity<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> template. This can be ideal when using <a href="/confluence/display/CAMEL/Templating" title="Templating">Templating</a> to generate responses for requests.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">velocity:templateName</pre>
</div></div>

<p>Where <b>templateName</b> is the classpath-local URI of the template to invoke; or the complete URL of the remote template (eg: <span class="nobr"><a href="file://folder/myfile.vm" title="Visit page outside Confluence" rel="nofollow">file://folder/myfile.vm<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>).</p>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Option </th>
<th class='confluenceTh'> Default </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> loaderCache </td>
<td class='confluenceTd'> true </td>
<td class='confluenceTd'> Velocity based file loader cache </td>
</tr>
<tr>
<td class='confluenceTd'> contentCache </td>
<td class='confluenceTd'> false </td>
<td class='confluenceTd'> New option in Camel 1.4. Cache for the resource content when its loaded. </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Headers"></a>Headers</h3>
<p>Camel will store a reference to the resource in the message header in the key <tt>org.apache.camel.velocity.resource</tt>. The Resource is an <tt>org.springframework.core.io.Resource</tt> object.</p>

<p>In Camel 1.4 headers set during the velocity evaluation is returned to the message and added as headers. Then its kinda possible to return values from Velocity to the Message.</p>

<p>An example: Set the header value of fruit in the Velocity template .tm:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">$in.setHeader('fruit', 'Apple')</pre>
</div></div>

<p>The header 'fruit' is now accessible from the <tt>message.out.headers</tt>.</p>

<h3><a name="BookComponentAppendix-VelocityContext"></a>Velocity Context</h3>
<p>Camel will provide exchange information in the Velocity context (just a Map). The Exchange is transfered as:</p>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> key </th>
<th class='confluenceTh'> value </th>
</tr>
<tr>
<td class='confluenceTd'> exchange </td>
<td class='confluenceTd'> The Exchange itself </td>
</tr>
<tr>
<td class='confluenceTd'> headers </td>
<td class='confluenceTd'> The headers of the in message </td>
</tr>
<tr>
<td class='confluenceTd'> camelContext </td>
<td class='confluenceTd'> The Camel Context </td>
</tr>
<tr>
<td class='confluenceTd'> request </td>
<td class='confluenceTd'> The in message </td>
</tr>
<tr>
<td class='confluenceTd'> in </td>
<td class='confluenceTd'> The in message </td>
</tr>
<tr>
<td class='confluenceTd'> body </td>
<td class='confluenceTd'> The in message body</td>
</tr>
<tr>
<td class='confluenceTd'> out </td>
<td class='confluenceTd'> The out message (only for InOut message exchange pattern) </td>
</tr>
<tr>
<td class='confluenceTd'> response </td>
<td class='confluenceTd'> The out message (only for InOut message exchange pattern) </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-Hotreloading"></a>Hot reloading</h3>
<p>The velocity template resource is by default hot reloadable for both file and classpath resources (expanded jar). Setting the contentCache=true then Camel will only load the resource once, and thus hot reloading is not possible. This scenario can be used in production usage when the resource never changes.</p>

<h3><a name="BookComponentAppendix-Samples"></a>Samples</h3>

<p>For example you could use something like</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"activemq:My.Queue"</span>).
  to(<span class="code-quote">"velocity:com/acme/MyResponse.vm"</span>);</pre>
</div></div>

<p>To use a velocity template to formulate a response for a message for InOut message exchanges (where there is a JMSReplyTo header).</p>

<p>If you want to use InOnly and consume the message and send it to another destination you could use</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"activemq:My.Queue"</span>).
  to(<span class="code-quote">"velocity:com/acme/MyResponse.vm"</span>).
  to(<span class="code-quote">"activemq:Another.Queue"</span>);</pre>
</div></div>

<p>And to use content cache, eg. for production usage where the .vm template never changes:</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"activemq:My.Queue"</span>).
  to(<span class="code-quote">"velocity:com/acme/MyResponse.vm?contentCache=<span class="code-keyword">true</span>"</span>).
  to(<span class="code-quote">"activemq:Another.Queue"</span>);</pre>
</div></div>

<p>And a file based resource:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"activemq:My.Queue"</span>).
  to(<span class="code-quote">"velocity:file:<span class="code-comment">//myfolder/MyResponse.vm?contentCache=<span class="code-keyword">true</span>"</span>).
</span>  to(<span class="code-quote">"activemq:Another.Queue"</span>);</pre>
</div></div>

<h3><a name="BookComponentAppendix-TheEmailSample"></a>The Email Sample</h3>
<p>In this sample we want to use Velocity as templating for an order confirmation email. The email template is laid out in Velocity as:</p>
<div class="code"><div class="codeContent">
<pre class="code-java">Dear ${headers.lastName}, ${headers.firstName}

Thanks <span class="code-keyword">for</span> the order of ${headers.item}.

Regards Camel Riders Bookstore
${body}</pre>
</div></div>

<p>And the java code:</p>

<div class="code"><div class="codeContent">
<pre class="code-java"><span class="code-keyword">private</span> Exchange createLetter() {
    Exchange exchange = context.getEndpoint(<span class="code-quote">"direct:a"</span>).createExchange();
    Message msg = exchange.getIn();
    msg.setHeader(<span class="code-quote">"firstName"</span>, <span class="code-quote">"Claus"</span>);
    msg.setHeader(<span class="code-quote">"lastName"</span>, <span class="code-quote">"Ibsen"</span>);
    msg.setHeader(<span class="code-quote">"item"</span>, <span class="code-quote">"Camel in Action"</span>);
    msg.setBody(<span class="code-quote">"PS: Next beer is on me, James"</span>);
    <span class="code-keyword">return</span> exchange;
}

<span class="code-keyword">public</span> void testVelocityLetter() <span class="code-keyword">throws</span> Exception {
    MockEndpoint mock = getMockEndpoint(<span class="code-quote">"mock:result"</span>);
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived(<span class="code-quote">"Dear Ibsen, Claus\n\nThanks <span class="code-keyword">for</span> the order of Camel in Action.\n\nRegards Camel Riders Bookstore\nPS: Next beer is on me, James"</span>);

    template.send(<span class="code-quote">"direct:a"</span>, createLetter());

    mock.assertIsSatisfied();
}

<span class="code-keyword">protected</span> RouteBuilder createRouteBuilder() <span class="code-keyword">throws</span> Exception {
    <span class="code-keyword">return</span> <span class="code-keyword">new</span> RouteBuilder() {
        <span class="code-keyword">public</span> void configure() <span class="code-keyword">throws</span> Exception {
            from(<span class="code-quote">"direct:a"</span>).to(<span class="code-quote">"velocity:org/apache/camel/component/velocity/letter.vm"</span>).to(<span class="code-quote">"mock:result"</span>);
        }
    };
}</pre>
</div></div>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-VMComponent"></a>VM Component</h2>

<p>The <b>vm:</b> component provides asynchronous <span class="nobr"><a href="http://www.eecs.harvard.edu/~mdw/proj/seda/" title="Visit page outside Confluence" rel="nofollow">SEDA<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> behaviour so that messages are exchanged on a <span class="nobr"><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/BlockingQueue.html" title="Visit page outside Confluence" rel="nofollow">BlockingQueue<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> and consumers are invoked in a seperate thread pool to the producer.</p>

<p>This component differs from the <a href="/confluence/display/CAMEL/Queue" title="Queue">Queue</a> component in that VM supports communcation across CamelContext instances so you can use this mechanism to communicate across web applications, provided that the camel-core.jar is on the system/boot classpath</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">vm:someName</pre>
</div></div>

<p>Where <b>someName</b> can be any string to uniquely identify the endpoint within the JVM (or at least within the classloader which loaded the camel-core.jar)</p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-XMPPComponent"></a>XMPP Component</h2>

<p>The <b>xmpp:</b> component implements an XMPP (Jabber) transport.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">xmpp:<span class="code-comment">//[login@]hostname[:port][/room][?Options]</span></pre>
</div></div>

<p>The component supports both room based and private person-person conversations.</p>

<p>Example:<br/>
<tt>xmpp://superman@jabber.org/room33</tt></p>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-XQuery"></a>XQuery</h2>

<p>The <b>xquery:</b> component allows you to process a message using an <a href="/confluence/display/CAMEL/XQuery" title="XQuery">XQuery</a> template. This can be ideal when using <a href="/confluence/display/CAMEL/Templating" title="Templating">Templating</a> to generate respopnses for requests.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">xquery:templateName</pre>
</div></div>

<p>Where <b>templateName</b> is the classpath-local URI of the template to invoke; or the complete URL of the remote template.</p>

<p>For example you could use something like</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"activemq:My.Queue"</span>).
  to(<span class="code-quote">"xquery:com/acme/mytransform.xquery"</span>);</pre>
</div></div>

<p>To use a xquery template to forumulate a response for a message for InOut message exchanges (where there is a JMSReplyTo header).</p>

<p>If you want to use InOnly and consume the message and send it to another destination you could use</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"activemq:My.Queue"</span>).
  to(<span class="code-quote">"xquery:com/acme/mytransform.xquery"</span>).
  to(<span class="code-quote">"activemq:Another.Queue"</span>);</pre>
</div></div>

<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

<h2><a name="BookComponentAppendix-XSLT"></a>XSLT</h2>

<p>The <b>xslt:</b> component allows you to process a message using an <span class="nobr"><a href="http://www.w3.org/TR/xslt" title="Visit page outside Confluence" rel="nofollow">XSLT<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> template. This can be ideal when using <a href="/confluence/display/CAMEL/Templating" title="Templating">Templating</a> to generate respopnses for requests.</p>

<h3><a name="BookComponentAppendix-URIformat"></a>URI format</h3>

<div class="code"><div class="codeContent">
<pre class="code-java">xslt:templateName</pre>
</div></div>

<p>Where <b>templateName</b> is the classpath-local URI of the template to invoke; or the complete URL of the remote template. Refer to the <span class="nobr"><a href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/core/io/DefaultResourceLoader.html" title="Visit page outside Confluence" rel="nofollow">Spring Documentation for more detail of the URI syntax<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span></p>

<p>Here are some example URIs</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> URI </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <div class="code"><div class="codeContent">
<pre class="code-java">xslt:com/acme/mytransform.xsl</pre>
</div></div> </td>
<td class='confluenceTd'> refers to the file com/acme/mytransform.xsl on the classpath </td>
</tr>
<tr>
<td class='confluenceTd'> <div class="code"><div class="codeContent">
<pre class="code-java">xslt:file:<span class="code-comment">///foo/bar.xsl</span></pre>
</div></div> </td>
<td class='confluenceTd'> refers to the file /foo/bar.xsl </td>
</tr>
<tr>
<td class='confluenceTd'> <div class="code"><div class="codeContent">
<pre class="code-java">xslt:http:<span class="code-comment">//acme.com/cheese/foo.xsl</span></pre>
</div></div> </td>
<td class='confluenceTd'> refers to the remote http resource </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-UsingXSLTendpoints"></a>Using XSLT endpoints</h3>

<p>For example you could use something like</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"activemq:My.Queue"</span>).
  to(<span class="code-quote">"xslt:com/acme/mytransform.xsl"</span>);</pre>
</div></div>

<p>To use a xslt template to forumulate a response for a message for InOut message exchanges (where there is a JMSReplyTo header).</p>

<p>If you want to use InOnly and consume the message and send it to another destination you could use</p>

<div class="code"><div class="codeContent">
<pre class="code-java">from(<span class="code-quote">"activemq:My.Queue"</span>).
  to(<span class="code-quote">"xslt:com/acme/mytransform.xsl"</span>).
  to(<span class="code-quote">"activemq:Another.Queue"</span>);</pre>
</div></div>

<h3><a name="BookComponentAppendix-SpringXMLversions"></a>Spring XML versions</h3>

<p>To use the above examples in Spring XML you would use something like</p>

<div class="code"><div class="codeContent">
<pre class="code-xml"><span class="code-tag">&lt;camelContext xmlns=<span class="code-quote">"http://activemq.apache.org/camel/schema/spring"</span>&gt;</span>
    <span class="code-tag">&lt;route&gt;</span>
      <span class="code-tag">&lt;from uri=<span class="code-quote">"activemq:My.Queue"</span>/&gt;</span>
      <span class="code-tag">&lt;to uri=<span class="code-quote">"xslt:org/apache/camel/spring/processor/example.xsl"</span>/&gt;</span>
      <span class="code-tag">&lt;to uri=<span class="code-quote">"activemq:Another.Queue"</span>/&gt;</span>
    <span class="code-tag">&lt;/route&gt;</span>
  <span class="code-tag">&lt;/camelContext&gt;</span></pre>
</div></div>

<p>There is a <span class="nobr"><a href="http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/XsltTest.java" title="Visit page outside Confluence" rel="nofollow">test case<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> along with <span class="nobr"><a href="http://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/XsltTest-context.xml" title="Visit page outside Confluence" rel="nofollow">its Spring XML<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span> if you want a concrete example.</p>
<h3><a name="BookComponentAppendix-Options"></a>Options</h3>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> converter </td>
<td class='confluenceTd'> null </td>
<td class='confluenceTd'> Option to override default <span class="nobr"><a href="http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/converter/jaxp/XmlConverter.html" title="Visit page outside Confluence" rel="nofollow">XmlConverter<sup><img class="rendericon" src="/confluence/images/icons/linkext7.gif" height="7" width="7" align="absmiddle" alt="" border="0"/></sup></a></span>. Will lookup for the converter in the <a href="/confluence/display/CAMEL/Registry" title="Registry">Registry</a>. The provided converted must be of type org.apache.camel.converter.jaxp.XmlConverter. </td>
</tr>
</tbody></table>

<h3><a name="BookComponentAppendix-SeeAlso"></a>See Also</h3>

<ul>
	<li><a href="/confluence/display/CAMEL/Configuring+Camel" title="Configuring Camel">Configuring Camel</a></li>
	<li><a href="/confluence/display/CAMEL/Component" title="Component">Component</a></li>
	<li><a href="/confluence/display/CAMEL/Endpoint" title="Endpoint">Endpoint</a></li>
	<li><a href="/confluence/display/CAMEL/Getting+Started" title="Getting Started">Getting Started</a></li>
</ul>

</div></div>


</td></tr></table></div>
<p>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td height="12" background="http://cwiki.apache.org/confluence/images/border/border_bottom.gif"><img src="http://cwiki.apache.org/confluence/images/border/spacer.gif" width="1" height="1" border="0"/></td>
    </tr>
</table>

<div class="smalltext">
    Powered by
    <a href="http://www.atlassian.com/software/confluence/default.jsp?clicked=footer" class="smalltext">Atlassian Confluence</a>
    (Version: 2.2.9 Build:#527 Sep 07, 2006)
    -
    <a href="http://jira.atlassian.com/secure/BrowseProject.jspa?id=10470" class="smalltext">Bug/feature request</a><br/>
    <br>
    <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action">Unsubscribe or edit your notifications preferences</a>

</div>

</body>
</html>


Mime
View raw message