C Client Guide
C Client Guide
C Client Guide
Aurea SonicMQ® C Client Guide 2013
Copyright © 2013 Aurea, Inc. All Rights Reserved. These materials and all Aurea Software, Inc. software products are
copyrighted and all rights are reserved by Aurea, Inc. This document is proprietary and confidential. No part of this
document may be disclosed in any manner to a third party without the prior written consent of Aurea Software, Inc. The
information in these materials is subject to change without notice, and Aurea Software, Inc. assumes no responsibility for
any errors that may appear therein.
Actional®, Actional (and design)®, SOAPscope®, SOAPstation®, Mindreef®, DataXtend®, Savvion®, Savvion (and
design)®, Savvion BusinessManager®, Dynamic Routing Architecture®, Sonic®, Sonic ESB®, Sonic Integration
Workbench®, Sonic Orchestration Server®, SonicMQ®, and SonicXQ® are registered trademarks of Aurea, Inc., in the
U.S. and/or other countries. Actional Agent™, Actional Intermediary™, Actional Management Server™, DataXtend
Semantic Integrator™, Pantero™, Savvion BizLogic™, Savvion BizPulse™, Savvion BizRules™, Savvion BizSolo™,
Savvion BPM Portal™, Savvion BPM Studio™, Savvion BusinessExpert™, Savvion BusinessManager™, Savvion Process
Asset Manager™, ProcessEdge™, Savvion Process Modeler™, Sonic Continuous Availability Architecture™, Sonic
Database Service™, and Sonic Workbench™ are trademarks or service marks of Aurea, Inc., in the U.S. and other countries.
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
All other marks contained herein are for informational purposes only and may be trademarks of their respective owners.
Third Party Acknowledgments: One or more products in the Aurea Sonic 2013 release includes third party components
covered by licenses that require that the following documentation notices be provided:
Aurea Sonic 2013 incorporates Another Tool for Language Recognition v2.7.4. Such technologies are subject to the
following terms and conditions: ANTLR Software License [Link] We reserve no legal rights to
the ANTLR--it is fully in the public domain. An individual or company may do whatever they wish with source code
distributed with ANTLR or the code generated by ANTLR, including the incorporation of ANTLR, or its output, into
commercial software. We encourage users to develop software with ANTLR. However, we do ask that credit is given to us
for developing ANTLR. By "credit", we mean that if you use ANTLR or incorporate any source code into one of your
programs (commercial product, research project, or otherwise) that you acknowledge this fact somewhere in the
documentation, research report, etc... If you like ANTLR and have developed a nice tool with the output, please mention that
you developed it using ANTLR. In addition, we ask that the headers remain intact in our source code. As long as these
guidelines are kept, we expect to continue enhancing this system and expect to make other tools available as they are
completed.
Aurea Sonic 2013 incorporates Apache Ant-Contrib 1.0B3. Such technology is subject to the following terms and
conditions: The Apache Software License, Version 1.1 - Copyright (c) 2001-2003 Ant-Contrib project. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user
documentation included with the redistribution, if any, must include the following acknowledgement: "This product
includes software developed by the Ant-Contrib project ([Link] Alternately, this
acknowledgement may appear in the software itself, if and wherever such third-party acknowledgements normally appear.
4. The name Ant-Contrib must not be used to endorse or promote products derived from this software without prior written
permission. For written permission, please contact ant-contrib-developers@[Link]. 5. Products derived from
this software may not be called "Ant-Contrib" nor may "Ant-Contrib" appear in their names without prior written permission
of the Ant-Contrib project. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ANT-CONTRIB
PROJECT OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Aurea Sonic2013 incorporates [Link], [Link], [Link],
[Link], [Link] from Sun Microsystems, Inc. These technologies are subject to the
following terms and conditions: Copyright 2000-2002 Sun Microsystems, Inc. All Rights Reserved. Redistribution and use
in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-Redistribution in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution. Neither the name of
Sun Microsystems, Inc. or the names of contributors may be used to endorse or promote products derived from this software
without specific prior written permission. This software is provided "AS IS," without a warranty of any kind. ALL
EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED
WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT,
ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES OR
LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR RELATING TO USE, MODIFICATION OR
DISTRIBUTION OF THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE
THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You acknowledge that Software is not designed,
licensed or intended for use in the design, construction, operation or maintenance of any nuclear facility.
Aurea Sonic 2013 incorporates Colt [Link]* packages v1.0.3 (ca1420-20040626). Such technology is subject to the
following terms and conditions: Packages [Link] , [Link]*, [Link] - Copyright (c) 1999 CERN - European
Organization for Nuclear Research. Permission to use, copy, modify, distribute and sell this software and its documentation
for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both
that copyright notice and this permission notice appear in supporting documentation. CERN makes no representations about
the suitability of this software for any purpose. It is provided "as is" without expressed or implied warranty.
Aurea Sonic 2013 incorporates Crimson v1.1.3. Such technology is subject to the following terms and conditions: The
Apache Software License, Version 1.1. Copyright (c) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user
documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes
software developed by the * Apache Software Foundation ([Link] Alternately, this acknowledgment
may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names
"Xerces" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software
without prior written permission. For written permission, please contact apache@[Link]. 5. Products derived from this
software may not be called "Apache", nor may "Apache" appear in their name, without prior written * permission of the
Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE
SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
====================================================================
This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation
and was originally based on software copyright (c) 1999, International Business Machines, Inc., [Link] For
more information on the Apache Software Foundation, please see <[Link]
Aurea Sonic 2013 incorporates DSTC Xs3P version 1.1 from DSTC Pty Ltd. Aurea will, at Licensee's request, provide
copies of the source code for this third party technology, including modifications, if any, made by Aurea. Aurea may charge
reasonable shipping and handling charges for such distribution. Licensee may also obtain the source code through
[Link] by following the instructions set forth therein. - DSTC Public License. The contents of this
file are subject to the DSTC Public License Version 1.1 (the 'License') (provided herein); you may not use this file except in
compliance with the License. Software distributed under the License is distributed on an 'AS IS' basis, WITHOUT
WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and
limitations under the License. The Original Code is xs3p. The Initial Developer of the Original Code is DSTC. Portions
created by DSTC are Copyright (c) 2001, 2002 DSTC Pty Ltd. All Rights Reserved.
Aurea Sonic 2013 incorporates Jing 20030619 and Trang 20030619. Such technology is subject to the following terms and
conditions: Copyright (c) 2002, 2003 Thai Open Source Software Center Ltd. All rights reserved. Redistribution and use in
source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution. Neither the name of the Thai Open Source
Software Center Ltd nor the names of its contributors may be used to endorse or promote products derived from this software
without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Aurea Sonic 2013 incorporates Model Objects Framework v2.0 from ModelObjects Group. Such technology is subject to
the following terms and conditions: The ModelObjects Group Software License, Version 1.0 - Copyright (c) 2000-2001
ModelObjects Group. All rights reserved. Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above
copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the
above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the
following acknowledgement: "This product includes software developed by the ModelObjects Group
([Link] Alternatively, this acknowledgement may appear in the software itself, if and wherever
such third-party acknowledgements normally appear. 4. The name "ModelObjects" must not be used to endorse or promote
products derived from this software without prior written permission. For written permission, please contact
djacobs@[Link]. 5. Products derived from this software may not be called "ModelObjects", nor may
ModelObjects" appear in thier name, without prior written permission of the ModelObjects Group. THIS SOFTWARE IS
PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE MODEL OBJECTS GROUP OR ITS CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Aurea Sonic 2013 incorporates Mozilla Rhino v1.5R3. The contents of this file are subject to the Netscape Public License
Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the
License at [Link] and a copy is provided below. Software distributed under the License is distributed
on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License. The Original Code is Mozilla Communicator client code,
released March 31, 1998. The Initial Developer of the Original Code is Netscape Communications Corporation. Portions
created by Netscape are Copyright (C) 1998-1999 Netscape Communications Corporation. All Rights Reserved. Aurea
will, at Licensee's request, provide copies of the source code for this third party technology, including modifications, if any,
made by Aurea. Aurea may charge reasonable shipping and handling charges for such distribution. Licensee may also obtain
the source code through [Link] by following the instructions set forth therein.
Aurea Sonic 2013 incorporates NET Security Library v1.0. Such technologies are subject to the following terms and
conditions: Copyright (c) 2002-2003, The KPD-Team All rights reserved. [Link] Redistribution and use
in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -
Neither the name of the KPD-Team, nor the names of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. Copyright (c) 2002-2003, The KPD-Team.
Aurea Sonic 2013 incorporates OpenSAML Java Distribution v1.0.1. Such technology is subject to the following terms and
conditions: The OpenSAML License, Version 1. Copyright (c) 2002 - University Corporation for Advanced Internet
Development, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided
with the distribution, if any, must include the following acknowledgment: "This product includes software developed by the
University Corporation for Advanced Internet Development [Link] Internet2 Project. Alternately, this
acknowledgement may appear in the software itself, if and wherever such third-party acknowledgments normally appear.
Neither the name of OpenSAML nor the names of its contributors, nor Internet2, nor the University Corporation for
Advanced Internet Development, Inc., nor UCAID may be used to endorse or promote products derived from this software
without specific prior written permission. For written permission, please contact opensaml@[Link]. Products
derived from this software may not be called OpenSAML, Internet2, UCAID, or the University Corporation for Advanced
Internet Development, nor may OpenSAML appear in their name, without prior written permission of the University
Corporation for Advanced Internet Development. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
AND CONTRIBUTORS "AS IS" AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED AND THE ENTIRE RISK OF
SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE. IN NO EVENT
SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY CORPORATION FOR ADVANCED
INTERNET DEVELOPMENT, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Aurea Sonic 2013 incorporates OpenSSL toolkit v0.9.8i. Such technologies are subject to the following terms and
conditions: LICENSE ISSUES ============== The OpenSSL toolkit stays under a dual license, i.e. both the conditions
of the OpenSSL License and the original SSLeay license apply to the toolkit. See below for the actual license texts. Actually
both licenses are BSD-style Open Source licenses. In case of any license issues related to OpenSSL please contact
openssl-core@[Link].
OpenSSL License ---------------
====================================================================
Copyright (c) 1998-2008 The OpenSSL Project. All rights reserved. Redistribution and use in source and binary forms, with
or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software must display the following acknowledgment: "This
product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. ([Link]
4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to endorse or promote products derived from
this software without prior written permission. For written permission, please contact openssl-core@[Link].
5. Products derived from this software may not be called "OpenSSL" nor may "OpenSSL" appear in their names without
prior written permission of the OpenSSL Project.
6. Redistributions of any form whatsoever must retain the following acknowledgment: "This product includes software
developed by the OpenSSL Project for use in the OpenSSL Toolkit ([Link] THIS SOFTWARE IS
PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR ITS
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
====================================================================
This product includes cryptographic software written by Eric Young (eay@[Link]). This product includes software
written by Tim Hudson (tjh@[Link]).
Original SSLeay License ----------------------- Copyright (C) 1995-1998 Eric Young (eay@[Link]) All rights
reserved. This package is an SSL implementation written by Eric Young (eay@[Link]). The implementation was
written so as to conform with Netscapes SSL. This library is free for commercial and non-commercial use as long as the
following conditions are aheared to. The following conditions apply to all code found in this distribution, be it the RC4,
RSA, lhash, DES, etc., code; not just the SSL code. The SSL documentation included with this distribution is covered by
the same copyright terms except that the holder is Tim Hudson (tjh@[Link]). Copyright remains Eric Young's, and
as such any Copyright notices in the code are not to be removed. If this package is used in a product, Eric Young should be
given attribution as the author of the parts of the library used. This can be in the form of a textual message at program startup
or in documentation (online or textual) provided with the package. Redistribution and use in source and binary forms, with
or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software must display the following acknowledgement: "This
product includes cryptographic software written by Eric Young (eay@[Link])" The word 'cryptographic' can be left
out if the rouines from the library being used are not cryptographic related :-).
4. If you include any Windows specific code (or a derivative thereof) from the apps directory (application code) you must
include an acknowledgement: "This product includes software written by Tim Hudson (tjh@[Link])" THIS
SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. The licence and distribution terms for any publically available version or derivative
of this code cannot be changed. i.e. this code cannot simply be copied and put under another distribution licence [including
the GNU Public Licence.]
Aurea Sonic 2013 incorporates Saxon XSLT and XQuery Processor v8.9.0.4 from Saxonica Limited
([Link] which is available from SourceForge ([Link] Aurea will, at
Licensee's request, provide copies of the source code for this third party technology, including modifications, if any, made
by Aurea. Aurea may charge reasonable shipping and handling charges for such distribution. Licensee may also obtain the
source code through [Link] by following the instructions set forth therein. - Mozilla Public License
Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the
License at [Link] and it is provided below. Software distributed under the License is distributed on
an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific
language governing rights and limitations under the License. The Original Code of Saxon comprises all those components
which are not explicitly attributed to other parties. The Initial Developer of the Original Code is Michael Kay. Until
February 2001 Michael Kay was an employee of International Computers Limited (now part of Fujitsu Limited), and
original code developed during that time was released under this license by permission from International Computers
Limited. From February 2001 until February 2004 Michael Kay was an employee of Software AG, and code developed
during that time was released under this license by permission from Software AG, acting as a "Contributor". Subsequent
code has been developed by Saxonica Limited, of which Michael Kay is a Director, again acting as a "Contributor". A small
number of modules, or enhancements to modules, have been developed by other individuals (either written specially for
Saxon, or incorporated into Saxon having initially been released as part of another open source product). Such contributions
are acknowledged individually in comments attached to the relevant code modules. All Rights Reserved.
Aurea Sonic 2013 incorporates Xalan Java XSLT Parser v2.4.1 from the Apache Foundation. Such technology is subject to
the following terms and conditions: The Apache Software License, Version 1.1 - Copyright (c) 1999 The Apache Software
Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided
with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following
acknowledgment: "This product includes software developed by the Apache Software Foundation
([Link] Alternately, this acknowledgment may appear in the software itself, if and wherever such
third-party acknowledgments normally appear. 4. The names "Xalan" and "Apache Software Foundation" must not be used
to endorse or promote products derived from this software without prior written permission. For written permission, please
contact apache@[Link]. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear
in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED
``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
===============================================================
This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation
and was originally based on software copyright (c) 1999, Lotus Development Corporation., [Link] For more
information on the Apache Software Foundation, please see <[Link]
Aurea Sonic 2013 incorporates Xerces v2.6.2 from the Apache Foundation. Such technology is subject to the following
terms and conditions: The Apache Software License, Version 1.1 - Copyright (c) 1999-2004 The Apache Software
Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided
with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following
acknowledgment: "This product includes software developed by the Apache Software Foundation
([Link] Alternately, this acknowledgment may appear in the software itself, if and wherever such
third-party acknowledgments normally appear. 4. The names "Xerces" and "Apache Software Foundation" must not be used
to endorse or promote products derived from this software without prior written permission. For written permission, please
contact apache@[Link]. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear
in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED
``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
===============================================================
This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation
and was originally based on software copyright (c) 1999, International Business Machines, Inc., [Link] For
more information on the Apache Software Foundation, please see <[Link]
Aurea Sonic 2013 incorporates Progress DataDirect Connect for JDBC v5.1 and Progress DataDirect Connect XE for JDBC
v5.1 which incorporates HyperSQL database v1.8.0.10 from The HSQL Development Group. Such technology is subject
to the following terms and conditions: Copyright (c) 2001-2005, The HSQL Development Group All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the
following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the
HSQL Development Group nor the names of its contributors may be used to endorse or promote products derived from this
software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, [Link], OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Aurea Sonic 2013 incorporates Woodstox v3.2.8 and 4.1.2 which incorporates Stax2 API v3.1.1. Such technology is subject
to the terms and conditions of the following licenses: Copyright (c) 2004-2010, Woodstox Project
([Link] All rights reserved. Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the
above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce
the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution. 3. Neither the name of the Woodstox XML Processor nor the names of its contributors may
be used to endorse or promote products derived from this software without specific prior written permission. THIS
SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Aurea Sonic 2013 incorporates JAXB v2.1.13. Such technology is subject to the following terms and conditions: Jing
Copying Conditions Copyright (c) 2001-2003 Thai Open Source Software Center Ltd. All rights reserved. Redistribution
and use in source and binary forms, with or without modification, are permitted provided that the following conditions are
met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following
disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the
Thai Open Source Software Center Ltd nor the names of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Aurea Sonic 2013 incorporates ASM 3.3.1 from Inria France Telecom. Such technology is subject to the following terms
and conditions: Copyright (c) 2000-2011 INRIA, France Telecom. All rights reserved. Redistribution and use in source
and binary forms, with or without modification, are permitted provided that the following conditions are met: 1.
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright
holders nor the names of its contributors may be used to endorse or promote products derived from this software without
specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
About This Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Typographical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Aurea Sonic Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
SonicMQ Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Other Documentation in the SonicMQ Product Family . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Worldwide Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6. SSL Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Using SSL on the C Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Certificate Samples and Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Settings on a Broker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Using SSL Authentication with username and password . . . . . . . . . . . . . . . . . . . . . 100
Using SSL Authentication with mutual certificates . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Businesses can participate in enterprise messaging from legacy C applications that provide
the performance levels of native C programs to interact with SonicMQ messaging services.
This guide is for developers who are experienced with C. They are not expected to be
familiar with SonicMQ or JMS messaging concepts. This guide provides background
information on SonicMQ messaging concepts to develop messaging clients with the C
Client API. For more in-depth coverage, the guide references the appropriate sections of
the SonicMQ documentation.
Typographical Conventions
This section describes the text-formatting conventions used in this guide and a description
of notes, warnings, and important messages. This guide uses the following typographical
conventions:
• Bold typeface in this font indicates keyboard key names (such as Tab or Enter) and
the names of windows, menu commands, buttons, and other Sonic user-interface
elements. For example, “From the File menu, choose Open.”
• Bold typeface in this font emphasizes new terms when they are introduced.
• Monospace typeface indicates text that might appear on a computer screen other than
the names of Sonic user-interface elements, including:
• Code examples and code text that the user must enter
• System output such as responses and error messages
• Filenames, pathnames, and software component names, such as method names
• Bold monospace typeface emphasizes text that would otherwise appear in monospace
typeface to emphasize some computer input or output in context.
This guide highlights special kinds of information by shading the information area, and
indicating the type of alert in the left margin.
Note: A Note flag indicates information that complements the main text flow. Such
information is especially helpful for understanding the concept or procedure being
discussed.
Important: An Important flag indicates information that must be acted upon within the
given context to successfully complete the procedure or task.
Warning: A Warning flag indicates information that can cause loss of data or other
damage if ignored.
The Sonic documentation set includes the following books and API references.
SonicMQ Documentation
SonicMQ installations provide the following documentation:
• Aurea Sonic Installation and Upgrade Guide — The essential guide for installing,
upgrading, and updating SonicMQ on distributed systems, using the graphical,
console or silent installers, and scripted responses. Describes on-site tasks such as
defining additional components that use the resources of an installation, defining a
backup broker, creating activation daemons and encrypting local files. Also describes
the use of characters and provides local troubleshooting tips.
• Getting Started with Aurea SonicMQ — Provides an introduction to the scope and
concepts of SonicMQ messaging. Describes the features and benefits of SonicMQ
messaging in terms of its adherence to the JavaSoft JMS specification and its rich
extensions. Provides step by step instructions for sample programs that demonstrate
JMS behaviors and usage scenarios. Concludes with a glossary of terms used
throughout the SonicMQ documentation set.
• Aurea SonicMQ Configuration and Management Guide — Describes the configuration
toolset for objects in a domain. Also shows how to use the JNDI store for administered
objects, how integration with Progerss Actional is implemented, and how to use JSR
160 compliant consoles. Shows how to manage and monitor deployed components
including metrics and notifications.
• Aurea SonicMQ Deployment Guide — Describes how to architect components in
broker clusters, the Sonic Continuous Availability Architecture™ and Dynamic Routing
Architecture®. Shows how to use the protocols and security options that make your
deployment a resilient, efficient, controlled structure. Covers all the facets of HTTP
Direct, a Sonic technique that enables SonicMQ brokers to send and receive pure
HTTP messages.
• Aurea SonicMQ Administrative Programming Guide — Shows how to create
applications that perform management, configuration, runtime and authentication
functions.
• Aurea SonicMQ Application Programming Guide— Takes you through the Java
sample applications to describe the design patterns they offer for your applications.
Details each facet of the client functionality: connections, sessions, transactions,
producers and consumers, destinations, messaging models, message types and
message elements. Complete information is included on hierarchical namespaces,
recoverable file channels and distributed transactions.
• Aurea SonicMQ Performance Tuning Guide — Illustrates the buffers and caches that
control message flow and capacities to help you understand how combinations of
parameters can improve both throughput and service levels. Shows how to tune TCP
under Windows and Linux for the Sonic Continuous Availability Architecture™.
• SonicMQ API Reference — Online JavaDoc compilation of the exposed SonicMQ
Java messaging client APIs.
• Management Application API Reference — Online JavaDoc compilation of the
exposed SonicMQ management configuration and runtime APIs.
• Metrics and Notifications API Reference — Online JavaDoc of the exposed SonicMQ
management monitoring APIs.
• Aurea Sonic Event Monitor User’s Guide — Packaged with the SonicMQ installer, this
guide describes the Aurea Sonic logging framework to track, record or redirect metrics
and notifications that monitor and manage applications.
• Aurea SonicMQ .NET Client Guide — Packaged with the SonicMQ .NET client
download, this guide takes you through the C# sample applications and describes the
design patterns they offer for your applications. Details each facet of the client
functionality: connections, sessions, transactions, producers and consumers,
destinations, messaging models, message types and message elements. Includes
complete information on hierarchical namespaces and distributed transactions. The
package also includes online API reference for the Sonic .NET client libraries, and
samples for C++ and [Link].
• Aurea SonicMQ C Client Guide — Packaged with the SonicMQ C/C++/COM client
download, this guide presents the C sample applications and shows how to enhance
the samples, focusing on connections, sessions, messages, producers and
consumers in both the point-to-point and publish/subscribe messaging models.
Provides tips and techniques for C programmers and gives detailed information about
using XA resources for distributed transactions. The package also includes online API
reference for the SonicMQ C client.
• Aurea SonicMQ C++ Client Guide — Packaged with the SonicMQ C/C++/COM client
download, this guide presents the C++ sample applications and shows how to
enhance the samples, focusing on connections, sessions, messages, producers and
consumers in both the point-to-point and publish/subscribe messaging models.
Provides tips and techniques for C++ programmers and gives detailed information
about using XA resources for distributed transactions. The package also includes
online API reference for the SonicMQ C++ client.
• Aurea SonicMQ COM Client Guide — Packaged with the SonicMQ C/C++/COM client
download for Windows, this guide presents the COM sample applications under ASP,
and Visual C++. Shows how to enhance the samples, focusing on connections,
sessions, messages, producers and consumers in both the point-to-point and
publish/subscribe messaging models. Provides tips and techniques for COM
programmers. The package also includes online API reference for the SonicMQ COM
client.
• Aurea SonicMQ 2013 Resource Adapter for JCA User’s Guide for Weblogic Aurea
SonicMQ 2013 Resource Adapter for JCA User’s Guide for Weblogic — Packaged
with this JCA adapter in a separate download, this guide describes the Sonic
Resource Adapter for JCA and using it with a WebSphere application server.
• Aurea SonicMQ 2013 Resource Adapter for JCA User’s Guide for Weblogic —
Packaged with this JCA adapter in a separate download, this guide describes the
Sonic Resource Adapter for JCA and using it with a Weblogic application server.
• Aurea SonicMQ 2013 Resource Adapter for JCA User’s Guide for JBoss — Packaged
with this JCA adapter in a separate download, this guide describes the Sonic
Resource Adapter for JCA and using it with a JBoss application server.
• The release version number and serial number of SonicMQ that you are using. This
information is listed on the license addendum. It is also at the top of the SonicMQ
Broker console window and might appear as follows:
• The release version number and serial number of Sonic ESB that you are using. This
information is listed on the license addendum. It is also near the top of the console
window for a Sonic ESB Container. For example:
• The platform on which you are running Aurea Sonic products, and any other relevant
environment information.
• The Java Virtual Machine (JVM) your installation uses.
• Your name and, if applicable, your company name.
• E-mail address, telephone, and fax numbers for contacting you.
This chapter introduces Java Message Service (JMS) concepts and explains how these
concepts are implemented by SonicMQ. This chapter includes the following sections:
Messaging Concepts
SonicMQ implements standardized messaging concepts, providing an easy-to-use set of
interfaces and administrative tools. The Application Programming Interfaces comply with
the standards in the Sun Java Message Service specification, version 1.02.b.
Client Client
Application Application
A B
Client Client
Application Application
F C
Client Client
Application Application
E D
After applications are linked, they might be secure, fast, and reliable. However, direct
peer-to-peer communication has several limitations:
• Bringing large integrated systems online is often so expensive and time consuming
that systems might become obsolete as soon as they start to amortize their costs.
• Modifying application software with hard-coded communications is tedious and error
prone.
Client Client
Application Application
A B
Client Client
Broker
Application Application
F C
Client Client
Application Application
E D
There is a savings in connections since this topology requires only n connections for n
clients, and is more efficient because the broker manages security, logistics and protocols
for connections to clients.
This messaging topology can expand to increase reliability and performance, yet the clients
only have to connect to the appropriate port on their preferred broker system.
The JMS provider implements and manages a JMS application. The JMS provider includes
the JMS Client API and the SonicMQ Client run time accessed from within the client
application, the communications layer between the client and the broker, and the broker
architecture. The broker architecture and services are central to SonicMQ’s messaging
security, efficiency, scalability, and performance. The SonicMQ broker does the following:
Container
Broker
Container
Broker
Directory Service
JNDI Store
Agent Manager
Container
When a hosted component is a Directory Service, the broker located in the same container
as the Directory Service handles management communications for the Directory Service.
Containers communicate with the Directory Service by connecting to the broker colocated
with the Directory Service. The Directory Service installation includes a local JNDI store, a
file system that enables clients to look up a named connection factories or destinations
defined by administrators.
All the containers that communicate with a given Directory Service are in that Directory
Service’s domain.
Domain
Broker
Domain
Manager
Directory Service
JNDI Store
Agent Manager
Container
The set of components that manage a domain comprise the domain manager.
Client applications connect to brokers and are outside the scope of the domain. In this
illustration, one broker performs both management broker and messaging broker functions.
Domain
Client
Applications
Broker
Domain
Manager
Directory Service
JNDI Store
Agent Manager
Container
Client
Application A
Client
Management Management Messaging
Application
Console Broker Broker Producer to
Destination
Broker
Domain Destination
Manager Consumer from
Broker Destination
Directory 1 Client
Service Application B
JNDI Store
Agent
Manager
Container 1
Container .
Clustered Brokers
As the requirements for performance and availability increase in a deployment, the benefits
of clustering become apparent. Clustered brokers lets you add brokers to handle heavy
message loads or high connection counts by load balancing new connections to brokers in
the cluster.
Domain Producer
Application
Broker
Cluster 2
Node A
Broker Consumer
1 Application
Broker
3
Domain
Node A
Cluster
Node B
Cluster
Domain
Cluster
Node A
Cluster
Node DM Node B
Broker
Node C
By specifying routing definitions on a local node, client applications can send messages to
a local node in their domain, yet route to a topic or queue on a remote node. This proxy
broker functionality is SonicMQ’s Dynamic Routing Architecture® (DRA). Each business
manages the security for its users and routing while the conduit between businesses is
efficient and accessible for authenticated, authorized [Link] following illustration
shows the concept of an application connecting to a broker in one domain to provide a
routing of a message to a destination on a broker in another domain. A client application
connected to that broker can then receive the message.
OurDomain TheirDomain
OurClient TheirClient
Application Application
Broker
Consumer on Broker Producer to
Q1 OurBroker1 TheirBroker1 OurNode1::Q1
Dynamic Routing Definition
Queue Destination OurNode1
Q1
Node Node
OurNode1 TheirNode1
Continuous Availability
When striving for non-stop availability of enterprise resources, SonicMQ’s Continuous
Availability Architecture™ provides resilience and fault tolerance in several ways:
• Client connections can be fault tolerant. When the broker or the network experiences
a fault, the clients resume when the broker (or its backup) is available. Alternate
network paths reroute to other networks defined on the broker.
• Replicated brokers pairs enable failover to a standby broker when the active broker
fails. Fault tolerant client connections take advantage of this feature.
CLIENTS CONNECTED TO THE ACTIVE BROKER IN A SET OF FAULT TOLERANT REPLICATED BROKERS
ClientClient
Application
Applications Replicated Replicated
R E PL I CA T I O N C O NNE CT I O N ( S )
Fault Broker Broker
Tolerant
ACTIVE STANDBY
Client
Applications
C LIENTS CONNECTED TO F AULT TOLERANT R EPLICATED B ROKERS A FTER THE A CTIVE B ROKER F AILS
ClientClient
Application
Applications Replicated
Fault Broker
Tolerant
STANDALONE
Client
Applications
X
Client applications can specify an interest in a fault tolerant client connection when they
connect to brokers that are licensed for fault tolerance. The client will maintain its
connection and session information even if it experiences a dropped connection, waiting
for the broker to become available again.
While fault tolerant client connections are available on single brokers, replicated brokers
provide a more dramatic case for high availability. When clients are connected to an active
broker, that broker is synchronizing its entire set of client information and data with its
standby broker. In the event that the active broker goes down, the standby broker takes
over as the only broker, and assumes the standalone role. Clients that have fault tolerant
connections maintain their state and connect to the other broker to resume the session
seamlessly.
Performance tools — That assess flows and traffic to assist administrators in fine
tuning system performance.
See Appendix A, Comparing the C Client with the Java Client on page 119 for more
information.
The rest of this chapter describes you how SonicMQ applications works.
The connecting application can use the setTCPConnectionTimeout method to set a timeout
for connection attempts that do not succeed.
One or more sessions can be created within a connection. Each session establishes a
context for one thread where messages might be sent or received. Figure 4 shows a client
application where one connection is made through which one session is established. The
client application uses programmatic interfaces to the JMS Client API that are executed
through the SonicMQ client run time on the session.
Client Application
C
C Client API S
O
E
N
S
N
S
E
Broker
SonicMQ Client I
C
O
Run Time N
T
I
O
N
Note: See Chapter 4, High Availability Connections on page 75 for information about
concepts and techniques for client fault tolerance.
Concurrent Sessions
A client can create multiple sessions within a connection to the broker, each independently
sending and receiving messages. Sessions execute in parallel so that multiple threads are
active concurrently to optimize thread usage for co-dependent activities.
For example, a connection might have two sessions where one is receiving messages
while the other is sending messages, thus removing the possibility of concurrent activities
on a single thread.
A single session can be used for sending and receiving if careful programming ensures that
more than one thread does not have access to a session at one time.
Session Types
Each session is established with a declared intention for acknowledgement of messages.
A session can be either transacted or nontransacted, in which case one of several modes
can be specified for acknowledging messages.
Transacted Session
A SonicMQ session can be specified as transacted. The technology of transaction
processing significantly reduces the effort required to build applications by allowing
applications to combine a group of one or more messages with publisher-to-broker
ACID properties:
• Atomic — Either all the messages are delivered or all are ignored.
• Consistent — Business rules ensure the receiver behaves correctly.
• Isolated — Transacted messages are delivered serially.
• Durable — Messages are persistent.
When a transaction commits, its atomic unit of input is acknowledged and its series of
messages is sent. If a transaction rolls back, its produced messages (if any) are destroyed.
The completion of a session’s current transaction automatically begins the next transaction.
A local transaction session is a good example of a session function that can take advantage
of sending and receiving in a single session. When a transacted session commits, all the
sent messages in the session are released on the server destinations and all the received
messages are acknowledged.
Global Transactions
SonicMQ also includes programmatic facilities that enable SonicMQ applications to fully
participate in global transactions—transactions that extend beyond a single session. In
global transactions, a transaction identifier is registered with a transaction manager that
manages the various branches of the transaction as it is constructed and then controls the
orderly preparation and commitment of the completed transaction.
Transaction Timeout
Because transactions buffer messages sent and received, a transaction that is stalled or
interrupted might have messages stuck in transit. Messages received in the transaction
context are neither acknowledged nor available to other consumers. Messages sent are not
accessible to receivers so the messages are invisible.
This situation can be handled by setting a broker limit on the amount of time that a
transaction can take to complete. An overdue transaction is rolled back, freeing queued
messages for other receivers.
While acknowledgement sets standards for message delivery, there is no reply to the
sender. If a reply to the sender is required, a message attribute is reserved for the request.
The requestor can also append a correlation identifier in the message’s header to ensure
that the reply matches its request.
C
O
S
N
E
N
S PRODUCER publishes, sends
E
S Messages
C Broker
I
T CONSUMER subscribes, receives
O
I
N
O
N
The producer of the message packages and encrypts the message body, identifies the
service level and protection for the outbound message, and then sends the message to its
destination (a specified location in the broker’s realm).
• Synchronous delivery — The client requests the next message using a receive
method that polls the session, which is the fundamental problem with traditional
system interconnections: the connection could be blocked indefinitely.
• Asynchronous delivery — The client registers a MessageListener. As messages
arrive, SonicMQ calls the listener’s onMessage method. With an asynchronous
connection, if the connection is in any way impaired, messages that are guaranteed
will wait for a connection to be re-established. The producer can determine how long
a message will wait for a consumer to avoid backlogs.
Delivery Mode
There are alternative delivery modes for a message:
• When a message is sent to a destination, you can specify that the message will always
be stored in a local log or data store before it is acknowledged as being transferred.
This PERSISTENT delivery mode ensures that a message is safe from normal system
outages and interruptions—whether in its initial transfer to the broker, in durable
subscriptions or queues on the broker, and even in transfers to other brokers and
queues.
• When messages have a NON_PERSISTENT delivery mode, the message throughput is
faster but messages are volatile—they might not be recoverable from an outage.
• Additionally, Pub/Sub offers a DISCARDABLE delivery mode so that high-volume
publishing systems can provide relief to fast subscribers when slow subscribers fall
way behind the incoming message flow.
Destinations
Destinations are the delivery labels in messaging. Rather than the place where the
message is ultimately delivered, a destination is the named staging area for the message.
SonicMQ distinguishes the two JMS messaging models:
These messaging models are very similar in terms of connection and session
management, message structure (types, headers, and properties), delivery mode options,
and delivery methods (blocking or asynchronous).
Forwarding Messages
To assure that a message destined for a remote queue is properly stored, you might use
transaction semantics to refrain from releasing the sender until the message is forwarded
and acknowledged. SonicMQ reduces the overhead of such a single message transaction
with its unique acknowledge-and-forward send method.
E
H Synchronous receiver
G about to complete
acknowledgement
F
E
D C
Receiver with
front an exclusive message selector
B
A
A
Prefetch
buffer
Receiver with
PreFetch count of "2"
The messages in this illustration are being removed from the queue by three receivers:
By also using a QueueBrowser, this receiver can scan through a queue capturing the
ever-changing queue image as it progresses. The QueueBrowser mechanism can
also let the sender view the queue to see how message traffic is moving.
• A receiver with a PreFetch count of 2 took messages A and B off the queue. Message
B is held aside while message A is processed. When message B enters processing,
the threshold trigger causes the receiver to draw off two more messages. The broker
can keep track of these messages in process and, unless acknowledgement is
received, the messages will be reinstated into the queue.
In the PTP model, each message is a unique item. However, messages can disappear
without being delivered—a message expires when its time to live has passed.
In clusters or Dynamic Routing, a message could get stuck in a position where the sender
knows that the broker accepted the message but other brokers, routes, or destinations
could create a state of doubt about final delivery. An application can send messages with
properties that request that as a dead message, it be preserved or at least notify the
administrator that it was never delivered. This concept, a dead message queue (DMQ), can
work in concert with other Quality of Service features to provide guaranteed persistence in
the always-active yet sometimes-disconnected networking environment of modern
computing.
In Figure , the PTP session thread has senders producing messages to destinations
maintained by the broker, and receivers consuming messages that the broker forwarded
from queues where the session is waiting to receive messages.
S
E C
S O
S
N
Broker
I
O N SENDER sends messages to Queues
N
E
S C Messages Queue
E T RECEIVER receives messages from Queues
S
S
I
I O
O
N
N
• The first message received is the first message delivered. This first-in-first-out
technique makes the second through nth messages endure until that first message is
consumed. Even when no clients express interest in receiving messages from a
queue, messages wait for a receiver until the message expires. When a message’s
delivery mode is set to PERSISTENT, the message is stored so that even a broker
shutdown does not put it at risk.
• There is only one message consumer for a given message. Many receivers can
balance the load, but only one takes delivery of the message.
• When the message is acknowledged as delivered, it is removed from the queue
permanently. No other receiver sees it and no other receiver consumes it.
Authorized users of a Queue Browser can use durable sequential queues to view
messages without consuming them.
In Figure 8, several FIFO queues are shown that might exist on a broker. The queues are
shown to have different depths, illustrating that the stack of messages persists until
receivers take messages off the queue as fast as they are added. The queues also show
a receiver taking a message.
The receiver could be one of many receivers who are standing by to receive the top-most
message. On the middle queue (BQ) in Figure 8, multiple receivers are allowed but only
one receiver gets the message—a queued message gets delivered only once.
Broker
Queues
Senders
Receivers
S1
R1
AQ
R2
S2
R3
BQ
R4
S3
R5
CQ
Queues are the preferred for load-balancing where many diverse systems can share
processing operations mandated, such as heavy trading activities, credit card charges,
online shopping carts, auctions, reservations, and ticketing.
Producers of queue messages can use Dynamic Routing in queue messaging by using the
routing_node_name::queue_name syntax to send a message to a queue on a remote node.
See Chapter 1, Routing Nodes and the Dynamic Routing Architecture on page 18 for an
illustration of Sonic’s Dynamic Routing Architecture.
C
A
B Synchronous subscriber
A
Asynchronous durable subscriber
A
Asynchronous subscriber with
inclusive message selector
Broker
Figure 9 shows three subscribers who have each received message A and are about to
receive message B then message C:
In the Pub/Sub model, a topic might have any number of subscribers from none to millions.
There is no statistical feedback to the publisher to indicate demand, but there is also no
burden on the publisher when the number of subscribers increases sharply.
In Figure 10, the Pub/Sub session thread has publishers producing messages to topics
maintained by the broker and subscribers consuming messages that the broker delivered
from topics where the session is subscribed.
S
E
C
S O
S
Broker
N
I
O N PUBLISHER publishes messages to Topics
N E
S C Messages Topic
E
S
T SUBSCRIBER receives messages from Topics
S I
I O
O
N N
After delivery of the message, the broker checks to see if any of the subscribers to the topic
are durable subscribers—subscribers who expressed a durable interest in the message’s
topic. If, after initial delivery, any durable subscribers did not acknowledge delivery, the
message is retained until the expiration time in anticipation that a durable subscriber will
connect to the broker and accept delivery. The expiration time is calculated from the
time-to-live beyond the time of publication. A message can be set to live forever yet is
discarded as soon as delivery to all current subscribers and all durable subscribers is
complete.
Asynchronous subscribers use a message Event Listener that delivers messages to the
subscriber’s application for interpretation—de-encryption, parsing, and passing to the
message consumer’s methods.
Subscribers can filter the messages they receive by qualifying their subscriptions with
message selectors that evaluate message headers and properties (but not the content)
with expression strings created with a subset of SQL-92 semantics. These filtering tasks
for subscriber messages take place on the broker.
SonicMQ extends the JMS standard topic naming mechanism with topic hierarchies (also
referred to as hierarchical name spaces) specified with a dot-delimited name string like
[Link]. The effort is minimal for the publisher, yet there are significant
administrative security advantages to the client subscription. The subscribers to the topic
node can, if granted authority to do so:
or many other combinations with a few simple template characters. Subscribers to the root
topic (““) get all messages by using (#).
Figure 11 describes how publishers send messages to topics and how the messages are
routed to active and durable subscribers:
P1 S2
P2 S3
S4
S5
P3
Messages
A SonicMQ message is fully compliant with the JMS specification of a message with all
attributes implemented, plus a few important extensions. The message types are:
Important: The SonicMQ C Client does not support the other message types specified for
JMS—ObjectMessage, StreamMessage, and MapMessage—or the SonicMQ
extensions, the XMLMessage or the MultipartMessage. While an XMLMessage is
seen as a TextMessage, the message type can be accessed and unaccepted
types can be forwarded without changes. See Chapter A, Message Types on
page 119 for more information.
Structure
A message consists of:
• Properties — Message properties can be any of several data types: boolean, byte,
short, int, long, float, double, or String. Custom-defined properties provide
name-value pairs that can be named, typed, populated, sent, and then coerced by the
receiver into other acceptable data types. SonicMQ defines a few properties that are
used to manage undeliverable messages, set per-message encryption, and specify
message types.
• Body — The message body is a set of bytes interpreted as the designated message
type. The message body is actually optional—you can send a message without a body
where the header and property values contain all intended information.
Request/Reply
A message producer can specify that it wants more than just acknowledgement from the
broker that the broker received the message. The producer can set a flag indicating that it
would like any consumer of the message to provide an explicit acknowledgement directly
to the producer at a stated destination.
To confirm delivery to its consumer, the message field JMSReplyTo is used as an indicator
that a response is anticipated from the consumer and where that response message should
be sent. The action is, in effect, a reversal of roles where the consumer is asked to produce
the reply message and the original message producer waits at the temporary destination
to consume the return message. While this certifies delivery, in its simplest form, it is
synchronous and therefore a blocking action for the original producer. However, there are
mechanisms that enable asynchronous requests and replies.
Quality of Service
Each client application can independently configure the type of message delivery for a
particular destination. Quality of Service is supported by session options and producer
parameters:
In addition, SonicMQ has features that enable application designers to balance the
workload across several brokers, check the health of a connection, and resume lost
connections.
Quality of Protection
Even when assured of persistence, message integrity can be compromised so that
unauthorized entities can read or change the message. SonicMQ provides features that
enable a message to have an enhanced Quality of Protection (QoP) level:
• Integrity — The contents of the message cannot be altered without the recipient (and
possibly the sender) being informed of the changes.
• Privacy — The content of any individual message cannot be viewed by anyone other
than the intended recipient. When you choose Privacy, it includes Integrity as well.
Security
SonicMQ provides security options that can be mixed and matched to provide the best
balance of secure message transfer and performance in applications. For example:
• The secure protocol SSL can be used in one connection to a broker while another
connection could use unsecure protocols. Interbroker communication and dynamic
routings can use channel encryption.
• Authentication can use the client side login SPI, external authentication, or built-in
authentication techniques.
• Password-based encryption renders the broker parameter settings readable only by
the broker itself and an authorized administrator.
• User authorization and authentication can be enforced when a connection is
requested.
• Interbroker communication is constrained to authorized routings.
• Access to queues and topics can be read- or write-specific and set to a hierarchy of
destinations. This streamlines security policies for static queues. For dynamically
created hierarchical topics, permissions can be established for topics before they are
created.
You can get started with the SonicMQ C Client by installing the client and running the
sample applications. This chapter describes how to set up and run the SonicMQ C sample
applications and explains the messaging concepts the sample applications demonstrate.
You can then use these sample applications to develop your own SonicMQ messaging
applications in C. This chapter includes:
• Running the Sample Applications on page 36 describes how to start the SonicMQ
broker, set up your environment, start the sample applications, and how to compile the
sample applications after you modify them.
• Point-to-point (PTP) Sample Applications on page 41 describes how to run these
sample applications and explains the messaging concepts they illustrate.
• Publish and Subscribe (Pub/Sub) Sample Applications on page 45 describes how to
run these sample applications and explains the messaging concepts they illustrate.
• Interoperating with Other Language Samples on page 53 describes how to explore
various ways to implement a C application.
Note: Platforms and Compilers — Visit the Aurea Sonic web site at [Link]/sonic
for information about supported platforms, processors, and compilers for the C
client.
Downloading and Installing — Register at the Aurea Software web site to qualify
for access to the electronic download location for the C/C++/COM Client
documentation and appropriate platform packages. Expanding the packages on
the corresponding platform installs the software and the documentation.
Release Notes — See the Aurea SonicMQ C/C++/COM Client Release Notes in
the documentation package for information about known issues with the C client.
Note: The samples directory also includes the Distributed Transaction sample. This
sample is described in Chapter 7, Running the SonicMQ C XA Transaction Sample
on page 109.
The following sections describe how to run the SonicMQ C Client sample applications:
After you identify the SonicMQ broker installation you want to use, start the broker
according to the instructions for the product version and platform.
When the broker starts, the console window indicates that it is accepting TCP connections
on a port.
The samples default to localhost:2506—a broker using port 2506 on the same system,
localhost. If you use a different host or port, you must specify the host:port parameter
when you start each sample; for example:
The following sections detail the last option. You put the installation location into a root
variable, create a general script that sets the variable, then use the variable to amend the
PATH statement.
set SMQROOT=cclient_install_dir
set SMQROOT=cclient_install_dir
set PATH=%SMQROOT%\bin\release;%PATH%
2. Save the file as [Link] at an easily accessed location such as, for the C
samples, the root of the directory %SMQROOT%\samples.
3. Open a console window, and then run the script. For example, if you open a console
window to run the Talk sample at samples\C\QueuePTP\Talk, you can run your
setpath script by entering ..\..\..\setpath.
• export SMQROOT=install_dir/Solaris
• export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SMQROOT/bin/$BUILDMODE
Note: The library path referenced as LD_LIBRARY_PATH under Solaris, Linux, and other
UNIX platforms, has variations such as SHLIB_PATH under HP-UX and LIBPATH
under AIX.
Note: Consider all text to be case-sensitive. While there might be some platforms and
names where case is not distinguished, it is good practice to always use case
consistently.
1. Open a console window to the directory where the application executable will run. For
example:
• On Windows: install_dir\samples\C\QueuePTP\Talk
• On UNIX or Linux: install_dir/samples/C/QueuePTP/Talk
2. Enter the client application executable with its parameters. For example:
The files mk_c.bat (Windows) and mk_c.sh (UNIX/Linux) are included in the samples
directory for compiling and linking your sample applications. The following sections tell you
how to compile the Talk sample on the different platforms:
Note: Review the make files in a text editor for comments and settings that might be
useful for your platform, operating system, and compiler.
1. See Setting the Variables and Updating the PATH On Windows on page 37.
2. Set the .dll files ([Link] and [Link]) on the path of the file to be compiled.
This is typically _install_dir\bin\release.
3. Open a console window at the directory level of the sample you want to compile, for
example:
install_dir\Samples\C\QueuePTP\Talk
The batch file mk_c.bat compiles Talk.c and creates [Link] in the same directory.
• Set SMQROOT to point to the directory where the C Client libraries reside for your
platform. Using Solaris as an example:
export SMQROOT=install_dir/Solaris
export BUILDMODE=release
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SMQROOT/bin/$BUILDMODE
using the value you set for the $BUILDMODE variable, release or debug.
Note: The library path—referenced as LD_LIBRARY_PATH under Solaris, Linux, and other
UNIX platforms—has variations such as SHLIB_PATH under HP-UX and LIBPATH
under AIX.
Another method for setting these environment variables is to create a shell script file
containing these exported properties, then source this file to set the properties.
3. Edit the mk_c.sh file to set the following switches correctly in the command line:
-I$SMQROOT/include
• Set the library switch to point to the directory containing the [Link] file:
-L$SMQROOT/bin/$BUILDMODE
• The branch statement in mk_c.sh that determines the OS type and invokes the
appropriate compiler.
4. Change the current directory to the directory where the sample source file is, for
example: $SMQROOT/samples/C/QueuePTP/Talk
The shell file mk_c.sh runs, creating the C executable file [Link] in the Talk
directory.
• SelectorTalk — Shows how clients can define SQL qualifiers that message receivers
can apply to filter messages received.
Important: The PTP sample applications require the sample queues in the broker
database named SampleQ1, SampleQ2, SampleQ3, and SampleQ4. If they are not
present, see the Aurea SonicMQ Configuration and Management Guide to set
up these queues.
where:
You can also add the following optional switches to the commandline:
1. Open two console windows at the directory level of the Talk sample, for example:
install_dir\samples\C\QueuePTP\Talk
2. Start an instance of the application under unique user names in each console window,
specifying a queue for sending and receiving:
3. In one console window, type text and then press Enter to send the message.
Observe the message in the other console window preceded by the sending user’s
name.
You can use the Talk sample to demonstrate multiple receivers to the same sender.
Repeat the preceding steps, this time opening three console windows and specifying two
receivers to SampleQ2, in addition to the sender to SampleQ1:
Now send a series of messages from the Sender and observe how they appear on one or
the other of the Receiver windows.
This sample application also demonstrates how to deal with recovery after loss of
connection. It specifies an ExceptionListener for connection failure and
setPingInterval, to monitor the heartbeat of the broker by pinging the broker at a preset
interval, letting the thread sleep for a while but initiating reconnection if the broker does not
respond.
This sample application sends and receive messages on specified queues. If a receiver’s
connection is lost, the receiver attempts to reconnect and continue receiving messages
waiting on the queue.
1. Open two console windows at the directory level of the ReliableTalk sample
application, for example:
install_dir\samples\C\QueuePTP\ReliableTalk
2. Start an instance of the application under unique user names in each console window,
specifying a queue for sending and receiving:
Observe the messages that appear under the different user names as you enter
messages in each console window.
Observe that the missed messages are still available if the restart is within ten
minutes.
For information about setPingInterval, see the “SonicMQ Connections” chapter in the
Aurea SonicMQ Application Programming Guide.
For information about PERSISTENT message delivery, see Chapter 1, Delivery Mode on
page 25.
3. In the AAA window, type any text and then press Enter. The message is enqueued but
there is no receiver. The BBB selector string does not see any enqueued messages
except those that evaluate to South.
5. In that console window start a new session, changing the selector string:
SelectorTalk -u BBB -s North -qr SampleQ2 -qs SampleQ1
The session starts and the message that was enqueued is immediately received.
6. In the AAA window, again type any text and then press Enter. The message is
enqueued and the BBB selector string qualifies the message for delivery.
1. Open three console windows at the directory level of the Chat sample, for example:
install_dir\samples\C\TopicPubSub\Chat
2. Start an instance of the application under unique user names in each console window,
for example:
3. In each window, enter text and then press Enter to publish the message.
Observe that the messages appear under the assigned user names as you enter
messages in each console window.
When messages are published, they are delivered to all active subscribers. Some
subscribers register an enduring interest in receiving messages that were sent while they
are inactive. These durable subscriptions are permanent records in the broker database.
Whenever a subscriber connects to the topic again, all undelivered messages to that topic
that have not expired are delivered immediately. When sessions are running, DurableChat
messages look similar to Chat, but if one of the sessions is interrupted, messages are
retained for it by the broker.
1. Open at least three console windows at the directory level of the DurableChat sample,
for example:
install_dir\samples\C\TopicPubSub\DurableChat
2. Start an instance of the application under unique user names in each console window:
3. In each window, type text and press Enter to publish the message.
Observe that the messages appear under the assigned user names as you enter
messages in each console window.
Observe that the missed messages are still available if the restart is within thirty
minutes.
1. Open two console windows at the directory level of the HierarchicalChat sample, for
example:
install_dir\samples\C\TopicPubSub\HierarchicalChat
2. Start an instance of the application under unique user names in each console window:
3. Type text messages in both the USA and SALES console windows and press Enter to
publish the message.
Observe that messages published from the SALES console window to the sales topic
are not seen in the USA console window as it is listening for messages on the
[Link] topic.
Observe that messages published to the [Link] topic are received by the SALES
user listening to sales.*.
To SelectorChat:
1. In the Closer window, type any text and then press Enter. The text is only displayed
in that window. The Presenter selector string excludes the Sales message.
2. In the Presenter window, type any text and then press Enter. The text is only
displayed in that window. The Closer selector string excludes the Marketing
message.
4. In that console window start a new session, changing the selector string:
SelectorChat -u Closer -s Marketing
Type text in either window and then press Enter. The text is displayed in both windows. The
selector string matches and the message displays.
ReliableChat publishes and subscribes to a specified topic. Text you enter is published to
the topic with the user name. The message persists for thirty minutes if the subscriber is
not available. If the subscriber reconnects within that time, the message is delivered.
After you run the basic sample, the syntax is extended to demonstrate how fault tolerant
clients behave in the Sonic Continuous Availability Architecture. See Chapter 2, Extending
ReliableChat for Fault Tolerant Connections on page 50 for details.
1. Open at least three console windows at the directory level of the ReliableChat
sample, for example:
install_dir\samples\C\TopicPubSub\ReliableChat
2. Start an instance of the application under unique user names in each console window:
3. In each window, enter text and press Enter to publish a message. Observe that
messages appear under the assigned user names as you enter messages in all
console windows.
Observe that the missed messages are still available if the restart is within thirty
minutes.
See Chapter 4, Overview on page 76 for more information about fault tolerant connections
and references to the SonicMQ documentation on the fault tolerant architecture.
2. Note the host port of each of the replicating brokers. Assume that the primary broker
is the active broker.
install_dir\samples\C\TopicPubSub\ReliableChat
4. Start an instance of the application under unique user names in each console window:
5. Enter messages in the BOSTON and PARIS consoles. The messages are received by
both subscribers.
The broker fails over to its standby, the broker on host_B1B listening on port 2102. That
broker will standalone until the other broker resumes.
When the primary broker comes back on line, it will be the standby broker for the
active broker, the one listening on port 2102 of host_B1B.
The BOSTON console cannot resume. It does not have a fault tolerant connection and it
does not even know the host port of the active broker. Unless the connection list is
changed to include both brokers, BOSTON must wait until the active broker fails so that
the broker accepting connections will again be listening on port 2101 of host_B1P.
The connection list is evaluated. The first connection URL is dedicated to its standby
role so it is not accepting connections. The next connection URL succeeds in
connecting to host_B1B:2102.
The BOSTON console cannot resume. It does not have a fault tolerant connection. It
reconnects to host_B1P as a new connection.
A replier is set up to consume a text message, convert it to all uppercase or all lowercase
characters, and then publish it to the topic where the requestor waits for a reply.
Replier Program
A replier will consume a text message, fold the case, and then publish it to the topic where
the requestor waits for reply. When replier.c runs, it waits for messages to the
[Link] topic. When that message occurs, a response based on the
request is sent back to the requestor specified in the JMSReplyTo header. A replier waits for
the request and replies with a message.
Default: localhost:2506
-u username Must be unique (checked when using a secure broker
Default: SampleReplier
-p password Password for user (checked when using a secure broker)
Default: password
-m mode Replier mode (uppercase, or lowercase)
Default: uppercase
Requestor Program
When requestor.c runs, it reads input and sends the text as a message to the
[Link] topic. This sample application replies with a simple text manipulation
of the request. The text is either changed to all uppercase or all lowercase. The
requestor.c sample application usage is:
Note: You must run the replier first; otherwise the synchronous request times
out.
1. Open two console windows at the directory level of the RequestReply sample, for
example:
install_dir\samples\C\TopicPubSub\RequestReply
Replier -u SampleReplier
Requestor -u SampleRequestor
4. Type a text message in lowercase in the requestor window and press Enter.
5. Start other requestors with different user names and observe that replies are not
broadcast to all users, for example:
Requestor -u SampleRequestorToo
6. Stop the Replier session by entering an empty line of text in its console window.
7. Start another Replier instance, this time using the lowercase reply mode:
8. Observe that all Replier instances are receiving all the messages (as they should)
and that the Requestor only receives one response.
For more about Request/Reply messaging, see Chapter 1, Request/Reply on page 32.
For more detailed information, see the “Message Producers and Consumers” chapter in the
Aurea SonicMQ Application Programming Guide.
1. Open a console window at the directory level of the C++ Talk sample, for example:
install_dir\samples\CPP\QueuePTP\Talk
2. Open a console window at the directory level of the C Talk sample, for example:
install_dir\samples\C\QueuePTP\Talk
3. Start an instance of the Talk application under unique user names in each console
window, specifying a queue for sending and receiving:
4. In the C++ client application console window, type text and then press Enter to send
the message.
You should see the message in C Client console window preceded by the user’s
name.
5. In the C Client application console window, type text and then press Enter to send the
message.
You should see the message in C++ client console window preceded by the user’s
name.
On UNIX or Linux, put the [Link] file in the client path (LD_LIBRARY_PATH on most
UNIX/Linux platforms) and copy the executable application file to the client machine. Then,
open console windows and run the samples as before.
This chapter examines the sample code provided with the SonicMQ C Client, and explains
how you can implement the features in the samples in your own applications. The chapter
also discusses some additional programming topics and explains how to interface with the
C API. The chapter includes:
• Working with the C Client API on page 55 explains the syntax and implementation of
the C Client API.
• Examining the Sample Application Code on page 68 explains how to establish
connections and sessions for messaging and illustrates these steps with code
excerpts from the SonicMQ C Client samples.
The SonicMQ C Client actively uses threads—Win32 threads on Windows and pthreads on
UNIX/Linux. Your application code must be multi-threaded when it interacts with SonicMQ.
The following sections provide information and advice for working with the C Client API.
Header Files
The header file, smqc.h, contains all of the C Client API declarations. Your C Client
application must include smqc.h in each source file that uses the client interface:
#include <smqc.h>
Macros
The header file, smqc.h, uses macros to represent C inheritance. These macros are a
convenience, but if you learn the API, you can program without them.
For example, if you look at the TextMessage section of smqc.h, it contains many #define
macros, including:
HOBJs
The C Client interface uses an HOBJ to represent every object. (An HOBJ is a handle to an
opaque object.) You pass an HOBJ into other methods, using C entry points that operate on
that type of object.
To obtain an HOBJ, call a factory method, as in this excerpt from the Talk.c sample
application:
Obtaining an HOBJ
/* Create string objects to work with. */
if ((String_create2(broker, &brokerObj) != 0) ||
(String_create2((char *)"", &connectIdObj) != 0) ||
(String_create2(username, &usernameObj) != 0) ||
(String_create2(password, &passwordObj) != 0) ||
(String_create2(sQueueName, &sQueueNameObj) != 0) ||
(String_create2(rQueueName, &rQueueNameObj) != 0))
{
fprintf(stderr, "Error creating String object(s)\n");
handleJMSException();
goto exit_cleanly;
}
Here, String_create2 is the factory that takes a char* as a parameter and returns an HOBJ
representing a string and a status code.
Since there are many string factories, they are distinguished by numeric designations; for
example, here 2 is appended to String_create.
From the HOBJ, you can query its type with Message_getType, as in this excerpt from the
Talk.c sample application:
You can also use Message_type( ) to check whether a message is the type you require,
for example, a text message. Use Message_instanceof( )and pass it the message HOBJ
that was sent. Then use another parameter for the result, TRUE or FALSE, as in this excerpt
from the Talk.c sample application:
text = NULL;
}
Bytes Message
For a BytesMessage, use an HOBJ that points to a jbyteArray to create an array then use
jbyteArrayRef when reading and sending the message.
Handling Strings
The C Client API works almost exclusively with HOBJs to represent string objects, rather
than with arrays of characters. This reflects the platform-independent implementation in
C++ of the C Client library. The exceptions are the string factory API that take char* or
wchar_t* as parameters and the AString_*, WString_*, and UTF8String_* APIs that
return char* and wchar_t* respectively.
This approach requires an extra step to get text into or out of the system. Therefore, the
String_* API contains many of the typical string operations. If you are examining or altering
a string HOBJ to submit it back to the C Client, you might consider operating directly on the
HOBJ, rather than extracting the character array.
This excerpt from the Talk.c sample application obtains the message text as an HOBJ and
then calls a helper function, copyOutString( ), to extract a char* for output to the console:
if (TextMessage_getText(aMessage, &text) != 0)
{
fprintf(stderr, "Error retrieving text from TextMessage\n");
handleJMSException();
} else if ((string = copyOutString(text)) == NULL) {
fprintf(stderr, "Error copying text from TextMessage\n");
handleJMSException();
}
else {
fprintf(stdout, "%s\n", string);
free(string);
}
if (text)
{
String_release(text, &retval);
text = NULL;
}
else {
int msgType;
if (Message_getType(aMessage, &msgType) != 0) {
fprintf(stderr, "Error getting message type\n");
handleJMSException();
}
else {
fprintf(stderr, "Unsupported message type received: %d\n", msgType);
}
}
Sending a BytesMessage
Data is moved to a jbyteArray to a BytesMessage for sending:
Myfunc ()
{
typedef MyStruct;
MyStruct foo;
HOBJ byteValues;
jbyte *ptr;
Receiving a BytesMessage
On receipt of a BytesMessage, data moves from the BytesMessage to a jbyteArray:
Callback Functions
In the C Client, asynchronous messages and exceptions are specified as callback function
pointers. The application must keep track of the listener contexts if there is more than one,
as the callback functions receive only a single message or exception HOBJ.
if (QueueReceiver_setMessageListener(receiver, onMessage) != 0)
{
fprintf(stderr, "Error setting message listener\n");
handleJMSException();
goto exit_cleanly;
}
Releasing Objects
/* Clean up. Order doesn't matter. */
if (msg)
Message_release(msg, &retval);
If you do not release the HOBJs, remaining references will cause memory leaks. Note that
all *_release API are mapped to Object_release so that Object_release can be called to
release any HOBJ.
Also, be sure to close and destroy connections or they will cause memory leaks. The
correct sequence is to close the producer (publisher or sender), then the session, and then
the connection.
Every _release() function decrements its argument object’s ref count, and objects are
destroyed when their ref counts reach 0. When you are done with an HOBJ, release it—if
the Sonic Client runtime needs a reference to that object, it will keep that reference and
your _release will not destroy the object. If the runtime needs to copy the contents of the
object into some other representation, it will do it and will not keep a reference to the original
object so that your _release() will destroy the object (provided that it was the last reference
to it.)
In summary, release HOBJs when your code does not need them anymore and trust the
runtime to do the right thing. (In much the same way that the Win32 API exposes kernel
objects via handles to them and operations on those handles.)
The following C code example sets and then releases string properties.
HOBJ property_name_obj = 0;
HOBJ property_value_obj = 0;
HOBJ message_obj = 0;
To try it, copy the text in Example of releasing objects on page 60, and then build it.
Exceptions
Exceptions cannot be thrown or caught in C, but they are in the C Client API because of
the exception listener, a way for an application to watch for dropped connections. If an HOBJ
is sent to your exception listener callback you can pass it back into the exception entry
points, for example, Exception_getMessage, to extract the message for further processing.
The application must release the HOBJ when it finishes with it.
SonicMQ exceptions result in C function return values that are nonzero. Using the
SMQ_getLastError() function interrogates the last error returned by a C API call, and
SMQ_getLastErrorText( ) retrieves the associated error text.
Retrieving Exceptions
/**
* See if there was an error during the last API call.
The library only keeps track of one exception per thread at a time. The next exception
causes the previous one to be destroyed if not queried by the application.
and defines a variable that the user will enter as a command line parameter:
char *selection;
When the user inputs a value for -s selection, these values are assembled after user input
as selectorString:
The selection test in this basic example is the property name to be tested for equivalence
to the given value. As described in the sample, the selectorString is Department, SALES
which formats into the SQL statement:
“Department=’SALES’”
The only messages in the receiver queue that will be delivered to the receiver are those
that have the property Department set to the value SALES.
Wide Characters
If your application uses Unicode characters, as either UCS-2 or UTF-8, use the most
appropriate alternate string factory methods and extraction classes.
Further manipulation of Unicode character data is outside the scope of the SonicMQ C
Client. The International Components for Unicode (ICU) is a C library that supports Unicode
on a wide variety of platforms. The ICU software is available under public license from IBM
at [Link]
ClientID All alphanumeric characters, ASCII punctuation and symbols are allowed
except period (.), asterisk (*), pound (#), slash (/), and dollar sign ($).
ConnectID All alphanumeric characters, ASCII punctuation and symbols are allowed
except period (.), asterisk (*), pound (#), slash (/). and dollar sign ($).
Durable All alphanumeric characters, ASCII punctuation and symbols are allowed
Subscription except period (.), dollar sign ($), slash (/), and backslash (\). Note that asterisk
(*) and pound sign (#) have wildcard meaning.
Queue All alphanumeric characters, ASCII punctuation and symbols are allowed
except backslash (\), slash (/), and dollar sign ($).
Note that:
Asterisk (*) and pound sign (#) have wildcard meaning when specifying
ranges of queue names in subscription names and ACLs.
Adjacent colons (::) are reserved for delimiting sections of global routing
names.
Routing Node All alphanumeric characters, ASCII punctuation and symbols are allowed
except asterisk (*), pound (#), dollar sign ($), slash (/), backslash (\), double
colon (::), and double quote (").
Topic All alphanumeric characters, ASCII punctuation and symbols are allowed
except slash (/), backslash (\) and single brackets ([ or ])
Note that:
Asterisk (*) and pound sign (#) have wildcard meaning.
Colon (:) is reserved for a remote topic name.
Adjacent colons (::) are reserved for delimiting sections of global routing
names.
Double brackets ([[ ]] )enclose a shared subscription identifier.
Names that begin with a dollar sign ($) or the character string “SonicMQ” are
reserved for system use.
User, All alphanumeric characters, ASCII punctuation and symbols are allowed
Routing User except asterisk (*), pound (#), dollar sign ($), slash (/), and backslash (\).
In SonicMQ, the Nagle algorithm is disabled by default. A Sonic C Client and the Sonic
broker can each set the TcpNoDelay option.
Broker Setting
The broker tunes the TcpNoDelay setting in its broker properties panel on the Tuning tab.
Setting the value to true disables the Nagle algorithm and minimizes small message
latency. A value of false enables the Nagle algorithm.
Client Setting
While the Java-based clients have the option of setting a virtual machine parameter or
using a Management API method to set the Nagle algorithm, neither of these techniques is
available in the C Client.
You can set the Nagle algorithm in SonicMQ C Client applications by using setter methods
as follows:
where
• true disables the Nagle algorithm and minimizes small message latency.
Connection Factories
To establish a connection with the SonicMQ broker, a client uses a ConnectionFactory
object. Model-specific factories are required for the Pub/Sub and PTP message models in
the SonicMQ C Client.
• QueueConnectionFactory
• TopicConnectionFactory
Note: In this chapter, references that are appropriate to either connection factory are
presented in the form: [Queue|Topic]ConnectionFactory.
Note: SonicMQ Java clients can use unified domain syntax as well as messaging model
specific syntax. QueueConnectionFactory and TopicConnectionFactory can be
used as well as the common ConnectionFactory. Java clients also require
distributed transactions to use the XAConnectionFactory, a model that is not
required in the C Client.
Minimize subscriber The connection factories support functionality to minimize subscriber traffic. When enabled,
traffic
the subscriber will attempt to flow control the broker immediately after the very first
message is received. The subscriber could receive more messages put on the wire by the
broker before it receives the flow control message. The sending will resume when the
subscriber's buffer becomes empty.
int TopicConnectionFactory_setMinimizeSubscriberTraffic
(HOBJ thisObj, jboolean minimizeTraffic);
where:
Connection Factory SonicMQ connection factory objects encapsulate the information needed to connect and
information
configure the SonicMQ JMS client connection, including:
The most essential connection factory settings are discussed in the following sections.
Important: Some characters are not allowed in SonicMQ names. In the context of
Connection Factory settings, generally period (.), asterisk (*), pound (#),
slash (/), and dollar sign ($) are not allowed. See Appendix A of the Aurea
Sonic Installation and Upgrade Guide for more information on using
characters in SonicMQ names.
URL
The Uniform Resource Locator (URL) identifies the host port and protocol for the
connection. The URL is in the form:
[protocol://]hostname[:port]
where:
• port is the port on the host where the broker is listening. The broker’s default
port value is 2506.
ConnectID
The ConnectID determines whether the broker allows multiple connections to be
established using a single username/ConnectID combination. You control the broker’s
behavior by calling the [Queue|Topic]ConnectionFactory_setConnectID method and
either providing a value (allow only one connection), or null (allow unlimited connections.)
When the broker is not security-enabled, these parameters are optional, and a named user
is simply a text label.
ClientID
The ClientID is a unique identifier to avoid conflicts for durable subscriptions when many
clients might be using the same username and the same subscription name.
• MessageProducers compress every message before sending it, and the broker
decompresses every message it receives on these connections.
• MessageConsumers decompress every message when received because the broker
compressed every message it delivered to the consumer on these connections.
When a SonicMQ client application enables message compression, the client negotiates
with the broker to which it is connecting to agree on the compression characteristics and
error checking. The actual compression and decompression functions are implicit when the
option is enabled.
Message compression has time and space requirements on both the client and the broker.
An administrator needs to determine which connections can offset the compression
overheads with the savings in message transfer time, and how many connections that
enable compression can be supported by the broker’s resources.
The “Talk Sample Application” on page 53 provides an option to enable compression at the
sample’s commandline to make it easy to explore this feature.
This option can be set on Connection Factories that are defined as Administered Objects.
See the Aurea SonicMQ Configuration and Management Guide for information.
The following sections use excerpts from various sample applications. For more
information on the sample applications, see Chapter 2, Getting Started with the C Client on
page 35.
The sample applications do not implement connection factories. Instead, they create
connections and sessions directly, as in the following excerpt from the Talk.c sample
application:
if (QueueConnection_createQueueSession(connection, 0,
Session_AUTO_ACKNOWLEDGE, &sendSession) != 0)
{
fprintf(stderr, "Error creating QueueSession\n");
handleJMSException();
goto exit_cleanly;
}
if (QueueConnection_createQueueSession(connection, 0,
Session_AUTO_ACKNOWLEDGE, &recvSession) != 0)
{
fprintf(stderr, "Error creating QueueSession\n");
handleJMSException();
goto exit_cleanly;
}
if (rQueueNameObj != NULL) {
if (QueueSession_createQueue(sendSession, rQueueNameObj, &rQueue) != 0) {
fprintf(stderr, "Error creating receiving queue\n");
handleJMSException();
goto exit_cleanly;
}
if (QueueReceiver_setMessageListener(receiver, onMessage) != 0) {
fprintf(stderr, "Error setting message listener\n");
handleJMSException();
goto exit_cleanly;
}
}
Starting a Connection
The following excerpt from the Talk.c sample application starts a connection:
Starting a Connection
/* Now that 'receive' setup is complete, start the Connection */
if (QueueConnection_start(connection) != 0) {
fprintf(stderr, "Error starting connection\n");
handleJMSException();
goto exit_cleanly;
}
Creating a Message
The following excerpt from the Talk.c sample application creates a message:
Creating a Message
/* Create a message from the string. */
else if (QueueSession_createTextMessage2(sendSession, textObj, &msg) != 0)
{
fprintf(stderr, "Error creating TextMessage\n");
handleJMSException();
}
Sending a Message
The following excerpt from the Talk.c sample application sends a persistent message and
specifies holding messages for 30 minutes (1,800,000 milliseconds):
Sending a Message
/* Send the message. Queues usually are used for PERSISTENT messages.
* Hold messages for 30 minutes (1,800,000 milliseconds).*/
else if (QueueSender_send2(sender, msg, DeliveryMode_PERSISTENT,
Message_DEFAULT_PRIORITY, MESSAGE_LIFESPAN) != 0)
{
fprintf(stderr, "Error sending message\n");
handleJMSException();
}
char *string;
HOBJ text;
text = NULL;
if (text) {
String_release(text, &retval);
text = NULL;
}
}
else {
int msgType;
if (Message_getType(aMessage, &msgType) != 0) {
fprintf(stderr, "Error getting message type\n");
handleJMSException();
}
else {
fprintf(stderr, "Unsupported message type received: %d\n", msgType);
}
}
if (QueueConnection_setClientID(connection, clientIDObj) != 0)
{
fprintf(stderr, "Error setting client ID\n");
handleJMSException();goto exit_cleanly;
}
if (QueueConnection_setPingInterval(connection, 30) != 0)
{
fprintf(stderr, "Error setting ping interval\n");
handleJMSException();
goto exit_cleanly;
}
if (QueueConnection_createQueueSession(connection, 0,
Session_CLIENT_ACKNOWLEDGE, &sendSession) != 0)
{
fprintf(stderr, "Error creating QueueSession\n");
handleJMSException();
goto exit_cleanly;
}
if (QueueConnection_createQueueSession(connection, 0,
Session_CLIENT_ACKNOWLEDGE, &receiveSession) != 0)
{
fprintf(stderr, "Error creating QueueSession\n");
handleJMSException();
goto exit_cleanly;
}
if (rQueueNameObj != NULL) {
if (QueueReceiver_setMessageListener(receiver, onMessage) != 0)
{
fprintf(stderr, "Error setting message listener\n");
handleJMSException();
goto exit_cleanly;
}
}
if (sQueueNameObj != NULL) {
This chapter explains the programming concepts and actions required to establish and
maintain high availability in SonicMQ connections through Aurea Sonic’s fault tolerance
mechanisms. This chapter contains the following sections:
Overview
Aurea Software’s Sonic Continuous Availability Architecture provides mechanisms for fault
tolerant management, replicated brokers, and fault tolerant client connections. A
fault-tolerant connection is designed to be resilient when it detects problems with the broker
or network. A standard connection, in contrast, is immediately dropped when the broker or
network fails. Because the standard connection is immediately dropped, your client
application has to explicitly deal with the situation, possibly trying to create a new
connection and resolve any in-doubt messages.
A fault-tolerant connection, unlike a standard connection, is kept alive when the broker or
network fails. It automatically performs several tasks when a problem occurs. For example,
it automatically attempts to reconnect when it encounters a problem with a connection. If it
successfully reconnects, it immediately executes several state and synchronization
protocol exchanges, allowing it to resynchronize client and broker state and resolve
in-doubt messages. When the connection successfully resynchronizes client and broker
state, the connection is said to be resumed, and your client application can continue its
operations without any directly visible disruption.
Fault-tolerant connections provide continuous operation across failures for JMS operations
that expect high availability:
For more information about fault tolerant deployments and continuous availability, see the
Aurea SonicMQ Deployment Guide. For more information about configuring fault tolerant
brokers, see the Aurea SonicMQ Configuration and Management Guide.
• Request that the connection be fault tolerant which will establish a contract between
the broker and the client to perform fault tolerant operations—provided that the broker
is licensed to provide continuous availability. The methods for this are:
QueueConnectionFactory_setFaultTolerant(HOBJ connObj,true)
TopicConnectionFactory_setFaultTolerant(HOBJ connObj,true)
• Supply a connection list with the primary and backup broker connection URLs:
QueueConnectionFactory_setConnectionURLs(HOBJ connObj,HOBJ
brokerList)
TopicConnectionFactory_setConnectionURLs(HOBJ connObj,HOBJ
brokerList)
• QueueConnectionFactory_setFaultTolerant(HOBJ connObj,jboolean
faultTolerant)
• TopicConnectionFactory_setFaultTolerant(HOBJ connObj,jboolean
faultTolerant)
You cannot create a fault-tolerant connection unless the broker is licensed to support fault
tolerance. A broker that is not licensed to support fault tolerance will effectively ignore the
ConnectionFactory setting.
To get the ConnectionFactory’s current fault-tolerance setting for new connections, call
one of the following methods:
• QueueConnectionFactory_getFaultTolerant(HOBJ connObj,jboolean
*pfaultTolerant)
• TopicConnectionFactory_getFaultTolerant(HOBJ connObj,jboolean
*pfaultTolerant)
Once connections are created, you can determine if the connection established a contract
as fault tolerant by calling the appropriate Connection_isFaultTolerant method.
The client runtime works through the list one URL at a time, and connects to the first
available broker on the list. The client runtime works through the list in sequential order,
either:
• Starting from a random entry in the list (to get this behavior, call the appropriate
ConnectionFactory_setSequential method).
The following code excerpt demonstrates setting setSequential to false to make the
client runtime randomly choose a broker from a list:
[Link](false);
HOBJ URLsObj
Connection_setConnectionURLs(URLsObj,“tcp://B1P:2101,tcp://B1B:210
2,tcp://B2P:2201,tcp://B2B:2202”);
The following code excerpt demonstrates setting setSequential to true to make the
client runtime choose a broker by starting at the beginning of the list:
Connection_setSequential(true);
• The following code excerpt demonstrates that if you change the list sequence, you can
specify that the primary brokers are attempted before their respective backup brokers.
This approach is appropriate, for example, if the backup brokers are on slower
machines than the primary brokers.
Connection_setSequential(true);
When the client runtime successfully establishes a fault tolerant connection with a broker,
the broker sends a list of URLs to the client runtime to be used for reconnection. When
replicating, the broker also sends a list of standby broker URLs for of reconnection.
After a connection is established, you can see the values in these lists by calling the
following methods on the connection:
The broker, for performance reasons, buffers transacted messages in memory, instead of
saving each message individually as it is received. Consequently, the client runtime also
buffers the unsaved messages, so that if the broker goes down and loses the buffered
messages, they can be automatically resent by the client runtime.
The broker Tuning parameter, Transactions: Buffer Size, specifies the size of the broker’s
buffer on a per-transaction basis. In general, performance improves as the buffer size is
increased. However, the improved performance has two costs: the client runtime uses
more memory, and it takes longer to resend the unsaved messages if the broker fails.
The client application can override the transaction buffer size by calling the
setClientTransactionBufferSize method:
• QueueConnectionFactory_setClientTransactionBufferSize(HOBJ
connObj,jlong size)
• TopicConnectionFactory_setClientTransactionBufferSize(HOBJ
connObj,jlong size)
• Zero (0) (the default value) — Indicates the broker Transaction Buffer Size is applied.
The client runtime must be able to buffer up to the broker Transactions Buffer Size
parameter per transaction.
• Positive Long integer — Specifies the size, in bytes, that the client runtime buffers
per transaction. If the buffer size is reached, JMS client sending threads block until
further messages are saved by the broker. The broker applies a buffer size that is the
lesser of the client-specified value and the broker’s Transactions: Buffer Size.
The client runtime must allocate sufficient memory to buffer messages for each active
transaction. For local transactions, each JMS Session can have at most one
transaction active. For global transactions, every active XA transaction branch is
considered an active transaction.
The broker flushes transacted messages to disk when the transacted messages exceed a
calculated amount: the lesser of the broker’s Transactions: Buffer Size parameter or the
fault-tolerant client’s transaction buffer size.
• QueueConnectionFactory_getClientTransactionBufferSize(HOBJ
connObj,jlong *psize)
• TopicConnectionFactory_getClientTransactionBufferSize(HOBJ
connObj,jlong *psize)
The client application can specify two timeouts related to fault tolerant connections:
• Initial connect timeout — How long the client runtime tries to establish an initial
connection to the broker.
• Fault tolerant reconnect timeout — How long the client runtime tries to resume a
fault tolerant connection after a problem is detected.
The client runtime continues to try to establish a connection until either a connection is
successful or the initial connect timeout is exceeded. If the client runtime is trying to connect
to a URL when a timeout occurs, it does not stop immediately. It must complete its current
attempt (and fail) before returning a failure to the client application. However, it can return
a failure before trying all URLs in the list.
• QueueConnectionFactory_setInitialConnectTimeout(HOBJ
connObj,jint seconds)
• TopicConnectionFactory_setInitialConnectTimeout(HOBJ
connObj,jint seconds)
If a connection cannot be established within the time, a connection exception is thrown. You
can get the existing initial connect timeout value by calling the appropriate method:
• int QueueConnectionFactory_getInitialConnectTimeout(HOBJ
connObj,jint *pseconds)
• int TopicConnectionFactory_getInitialConnectTimeout(HOBJ
connObj,jint *pseconds)
You can adjust the timeout or whether the attempts will ever timeout by setting either:
• QueueConnectionFactory_setFaultTolerantReconnectTimeout(HOBJ
connObj,jint seconds)
• TopicConnectionFactory_setFaultTolerantReconnectTimeout(HOBJ
connObj,jint seconds)
• A positive integer — Specifies a timeout; the client runtime will abandon further
reconnection attempts if the timeout is exceeded. The default timeout is 60 seconds.
• Zero (0) — Specifies no timeout: the client runtime will try to reconnect indefinitely.
If the client fails to reconnect in the allocated time, the client is completely disconnected by
the broker. A fault-tolerant client runtime that attempts to reconnect after the broker has
discarded state will encounter a connection failure. When the client runtime fails to resume
a connection, the client runtime drops the connection and returns a connection dropped
exception to the client application’s ExceptionListener.
You can get the existing FT reconnect timeout value by calling the appropriate method:
int QueueConnectionFactory_getFaultTolerantReconnectTimeout(HOBJ
connObj,jint *pseconds)
int TopicConnectionFactory_getFaultTolerantReconnectTimeout(HOBJ
connObj,jint *pseconds)
When a fault tolerant connection encounters a problem and cannot communicate with the
broker, the client runtime does not immediately drop the connection. Instead, it tries to
resume the connection. While it is trying to resume the connection, it defers passing any
exceptions to the client application. If it fails in its attempt to reconnect, it then passes the
exceptions to the client application as it would for a standard connection.
When a fault tolerant connection is working normally, the connection state is ACTIVE. If a
problem occurs with the connection, the client runtime changes the state to RECONNECTING
and attempts to resume the connection. If the attempt is successful, the client runtime
changes the state back to ACTIVE; if all attempts to reconnect fail, the client runtime
changes the state to FAILED. Finally, if an ExceptionListener is registered, the client
runtime calls its onException method.
While the client runtime is trying to resume a fault-tolerant connection, the client application
appears to block. However, the client application can stay informed about the state of the
connection by implementing a ConnectionStateChangeListener and registering it with the
appropriate Connection.
• Connection_setConnectionStateChangeListener
(HOBJ connObj, pfnCConnectionStateChangeListener listener, HOBJ
hobjUser)
• QueueConnection_setConnectionStateChangeListener
(HOBJ connObj, pfnCConnectionStateChangeListener listener, HOBJ
hobjUser)
• TopicConnection_setConnectionStateChangeListener
(HOBJ connObj, pfnCConnectionStateChangeListener listener, HOBJ
hobjUser)
You can get information about a connection state change listener by calling one of the
following methods:
• int Connection_getConnectionStateChangeListener
(HOBJ connObj, pfnCCSCL* p_pfncListener)
• int QueueConnection_getConnectionStateChangeListener
(HOBJ connObj, pfnCCSCL* p_pfncListener)
• int TopicConnection_getConnectionStateChangeListener
(HOBJ connObj, pfnCCSCL* p_pfncListener)
• int Connection_getConnectionStateChangeListenerHobjUser
(HOBJ connObj, HOBJ* hobjUser)
When you implement a ConnectionStateChangeListener, you must not perform any JMS
operations related to the connection, except for the informational Connection_ methods
getConnectionState, getBrokerURL, getBrokerReconnectURLs, and
getStandbyBrokerReconnectURLs.
In all these cases, a client application can determine which broker it is currently connected
to by calling the appropriate Connection_getBrokerURL method:
The method returns the URL of the currently connected broker. If the current connection
state is RECONNECTING, this method returns the URL of the last broker connected when the
connection state was ACTIVE. This method may be called after the connection is closed.
A client application can access the first list by calling the getBrokerReconnectURLs
method. The signatures of these methods are as follows:
These methods are used for purely informational purposes, such as for writing to an audit
log; the reconnect logic is automatically performed by the client runtime. These methods
can both be called after the fault-tolerant connection is closed
The broker reconnect URLs are derived from the configuration by the following rules:
• If the active broker has a default routing URL configured, return the currently
connected URL.
• If the active broker has one or more URLs with same acceptor name as the currently
connected URL, return the URLs with same acceptor name, and include the currently
connected URL (getBrokerURL).
• Otherwise return the currently connected URL (getBrokerURL).
Reconnect Errors
A fault-tolerant connection might fail to reconnect for a variety of reasons. When a failure
occurs, the ERR_CONNECTION_DROPPED error code is included in the exception returned to the
Connection’s ExceptionListener. A linked exception provides more information about the
specific cause of the failure.
To get:
• The URL of the broker that the client connects to as a result of load balancing, call
getBrokerURL on the connection object.
• The reconnect URLs of the broker that the client connects to as a result of load
balancing, call getBrokerReconnectURLs on the connection object.
• The URLs of the backup broker for the broker that the client connects to as a result of
load balancing, call getStandbyBrokerReconnectURLs on the connection object.
The general term failure means either a broker failure or a transient network failure. Some
of the behaviors after or failure are:
The phrase broker failure means one of the following—a broker crashed, recovered fully,
and restarted successfully; or a replicated broker crashed and failed over to its backup
broker. Some of the behaviors after broker failure are:
When a message is sent from a client to an active broker, the client maintains a copy of the
message until two acknowledgements are received. The first acknowledgement is from the
active broker, the second acknowldegement is from the standby broker through the active
broker. If the active broker fails before the second acknowledgement is returned,
then—when the client reconnects to the standby as it assumes the active state—it
negotiates its state: what was the last message received, what was the last
acknowledgement received by the client. When the now-active broker has synchronized
with the client, any missed messages are resent from the client cache. If the active broker
fails prior to replication, then—when the client negotiates its state at reconnection—missing
messages are resent from the client cache. Messages are removed from the client cache
after both acknowledgements are received.
Reconnect Conflict
Connect conflicts are possible during client connection recovery. Conflicts can happen at
the JMS connection level and at the durable subscriber level.
Message Reliability
The following table describes the message reliability levels for clients that reconnect to the
broker or its backup after a failure. The reconnect is automatic for fault tolerant connections,
application driven for standard connections. The table assumes that clients that reconnect
on standard connections do not resend in-doubt messages on reconnecting.
Standard DISCARDABL At most once1 At most once1 At most once1 At most once1
Connection E
Fault-Tolerant DISCARDABL At most once At most once At most once At most once
Connection E
Chapter 5, Using Login SPI for Sonic Authentication on page 91 describes using the
SonicMQ C client Service Provider Interface (SPI) which is used on the client side to
authenticate JMS client applications inwhich the broker uses Sonic’s external security
implementation, Pluggable Authentication and Security Service (PASS). Implementation of
this interface requires implementing the Authentication SPI and the Management SPI on
the broker side.
The Authentication SPI is used to authenticate JMS clients connecting to a broker via the
delegation mode, and to perform callback operations on the broker. The Management SPI
is used by the Sonic Directory Service to replicate users and credentials on the Sonic
Directory Service. This information is used in the Sonic Management Console to provide a
graphical read-only representation of users and groups in an external domain.
See the Aurea SonicMQ Administrative Programming Guide for information about the
Authentication SPI and the Management SPI as well as the Login SPI for Java clients. This
chapter contains the following sections:
Overview
You can implement an external security store for an authentication domain, in addition to
the local security store that is implemented by default for all authentication domains:
• Local security store — Users are stored in the Sonic Directory Service.
• External security store — Users are stored externally and accessed in the domain by
the Authentication SPI and the Management SPI. Passwords are stored in an external
security store in an unknown format. You must implement the Login SPI to perform
password transformations when using an external security store.
The SonicMQ C client includes sample code in its QueuePTP/Talk.c sample which you can
examine to understand how to implement these security features in your applications. This
chapter includes some code excerpts from the C client sample to illustrate how to
implement the PASS SPIs.
For information about the PASS features in SonicMQ, see the chapter “Security
Considerations in System Design” in the Aurea SonicMQ Deployment Guide.
See the chapter “Configuring Security” in the Aurea SonicMQ Configuration and
Management Guide for information about using the SMC to configure these security
features in SonicMQ.
SimpleLogin SPI
The SimpleLogin SPI provides access to the ILogin interfaces. When you implement the
SimpleLogin SPI, users can be authenticated with external authentication service before a
JMS connection is created.
2. The SonicMQ runtime calls the method getLoginSPI( ), which returns an ILogin
instance to be used for further authentication processing.
3. Upon successful instantiation of the class, the SonicMQ runtime passes the user
name and the password to the underlying SPI implementation using its CMap.
4. The SonicMQ runtime calls the method login( ) on the underlying SPI
implementation.
5. If the login( ) method returns without an exception, the login to external security
store or schema is assumed validated and the user is considered authenticated.
6. Upon successful return from the login( ) method, the SonicMQ runtime calls the
getTransformedUsername and getTransformedPassword functions to retrieve the user
credentials.
7. The retrieved user name, password, and transformed password are used to establish
a connection with the Sonic broker.
Methods
SimpleLogin methods:
void SimpleLoginCMap_init(ILoginSPICMap*)
• Callback methods:
void SimpleLoginCMap_setTransformedUsername(struct
_loginSPIMap *, HOBJ);
HOBJ SimpleLoginCMap_getTransformedUsername(struct
_loginSPIMap *);
void SimpleLoginCMap_setTransformedPassword(struct
_loginSPIMap *, HOBJ);
HOBJ SimpleLoginCMap_getTransformedPassword(struct
_loginSPIMap *);
Related APIs:
Sample
The following code provides excerpts from the Talk sample application that create a queue
connection to a SonicMQ broker, invoking the Login SPI implementation in the C client. The
sample assumes that the broker side has been set up for external authentication.
...
void Talk:talker(
char *broker,
char *username,
char *password,
char *qReceiver,
char *qSender,
jint timeout,
int login);
ILoginSPICMap login_cmap;
/* external authentication */
if (login)
SimpleLoginCMap_init(&login_cmap);
if (QueueConnectionFactory_setLoginSPI(connectionFactory,
&login_cmap)!= SMQ_SUCCESS) {
handleJMSException();
goto exit_cleanly;
4. Adds to the usage that a switch lets you choose to use the Login SPI:
Init();
SonicMQ supports encryption at the connection level through SSL. This chapter describes
the programming concepts and actions required to establish and maintain connections with
SonicMQ brokers through SSL in the SonicMQ C client.
See the Aurea SonicMQ Deployment Guide for more information about SSL. This chapter
includes the following section:
• Using SSL on the C Client on page 97 provides information on how to use SSL
certificates on the C client.
Note: The OpenSSL inclusions in the SonicMQ C client explicitly omit patented
algorithms, such as IDEA, MDC2, and RC5.
• Command line — Pass the SSL properties at the command line when starting the
application.
• Programmatically — Set the SSL properties in your application.
For optimal security, consider using LoginSPI in conjunction with SSL so that the
obfuscated credentials are encrypted at the connection level. See Chapter 5, Using Login
SPI for Sonic Authentication on page 91 for more information.
You can convert certificates used in a Java client to the PEM format for use by the C client.
• CA/[Link]
• client.p7c
• clientKey.pkcs8
c_rehash CA
5. Type the password when prompted. The password for the sample private key in the
certs folder is password. The password is stored in the PEM file that is created.
Note: The openssl commands refer to the OpenSSL utility built and packaged with the
Sonic C client. You can use the public OpenSSL utilities if you prefer to use them.
Authentication
Authentication is the process of presenting an identity to the broker and then providing a
password or certificate that certifies the user’s credentials.
Two methods are provided in the C client API to set SSL properties
• QueueConnectionFactory_setSSLProperties (connectionFactory,
ca, cc, pk, cs);
• TopicConnectionFactory_setSSLProperties (connectionFactory, ca, cc, pk,
cs);
wherein:
Settings on a Broker
In the configuration of SSL acceptors on a broker, each acceptor’s SSL tab lets you choose
to enable client authentication, as shown in the following image:
• When enabled, the broker mandates that the client present its certificate, referred to
as mutual authentication. Thus, the server presents its certificate in the handshake
and expects the client to present the client certicate to complete the handshake. The
client must specify CA CERT DIR, CERTIFICATE CHAIN, and PRIVATE KEY properties.
• When not enabled, only the broker presents its certificate in the handshake, referred
to as server-only authentication. The client must specify a CA CERT DIR property.
Samples
The following procedures show how to run a C client application with SSL:
• The broker where connection will be attempted has an acceptor setup for SSL on port
3000 that has chosen to not enable client authentication.
• The C client Talk sample will be used since it is preset to accept the properties and
use the SSL connection factories.
Note: See the Aurea SonicMQ Configuration and Management Guide for information on
defining acceptors and users.
The Talk sample application usage for SSL with username/password authentication is:
To run the SonicMQ C Talk sample application for SSL with username/password
authentication:
1. Open two command prompts and go to the directory of the the Talk sample in each
one, for example:
install_dir\samples\C\QueuePTP\Talk
2. Start an instance of the application using unique user names in each command
prompt, specifying a queue for sending and receiving:
3. In one command prompt, type a test message and then press Enter to send it.
4. Observe the message in the other commandprompt preceded by the sender’s name.
Assumptions:
• The broker where connection will be attempted has an acceptor setup for SSL on port
4000 that has chosen to enable client authentication.
Note: See the Aurea SonicMQ Configuration and Management Guide for information on
defining acceptors and users.
The Talk sample application usage for SSL with mutual authentication is:
To run the SonicMQ C Talk sample application with client authentication via mutual
certificates:
1. Open two command prompts and go to the directory of the the Talk sample in each
one, for example:
install_dir\samples\C\QueuePTP\Talk
2. Start an instance of the application using unique user names in each command
prompt, specifying a queue for sending and receiving:
3. In one command prompt, type a test message and then press Enter to send it.
Transaction Types
A single SonicMQ application can contain both local and global transactions.
From the transaction manager’s perspective, the actual implementation of the transaction
services does not need to be exposed. Only high-level interfaces must be defined to allow
transaction demarcation, resource enlistment, synchronization, and recovery process to be
driven by the users of the transaction services.
Resource Transaction
XA
Manager Manager
As RMs on diverse threads participate in the distributed transaction, it is crucial that the TM
establish and maintain the state of the transaction as it evolves. A transaction context
logically envelopes all the operations performed on transactional resources during the
transaction.
An application server can bring additional resources into the transaction, referred to as
resource enlistment. In Figure 2, another RM is participating in an XA connection to the
same TM as the owner.
Transaction
Manager
XA XA
Resource Resource
Manager Manager
The transaction context and resource enlistment can extend to other transaction managers,
as shown in Figure 3.
Resource Resource
RM 21 RM 22
Manager 11 Manager 12
XA XA
Transaction
TM 2
Manager 1
TM 3
RM 31 RM 32
Messages sent in the transaction context are not permanently recorded. Messages
received in the transaction context are not acknowledged until the owner ends the
transaction demarcation and passes control to its TM. This TM can coordinate with the
other involved TMs and RMs to prepare and commit the global transaction.
The transaction owner explicitly ends the global transaction. If the transaction involves a
single transaction manager, telling the TM to commit or rollback the transaction handles the
transaction state on all the participating branches.
A global transaction that involves multiple resource managers requires a two-phase commit
to request that the participants prepare for completion., when all are prepared, request that
the participants perform the commitment. It a failure occurs during the commitment
process, the state of the global transaction can be indoubt.
Phase 1: Commit
Resource
Manager
Released
Commit Transaction
Application
Manager
Phase 1: Commit
Resource
Manager
Released
In Figure 5, both resource managers, when commanded to prepare their contribution to the
transaction, responded positively. The global commit by the owner’s transaction manager
commits each branch of the global transaction.
Phase 1: Prepare
Ready !
Resource
Phase 2: Commit Manager
Released
Commit Transaction
Application
Manager
Phase 1: Prepare
Ready !
Resource
Phase 2: Commit Manager
Released
In Figure 6, one of the resource managers indicates that its portion of the global transaction
cannot complete. As a result, a global rollback is issued for each branch of the transaction.
Phase 1: Prepare
Ready !
Resource
Phase 2: Rollback Manager
Discarded
Commit Transaction
Application
Manager
Phase 1: Prepare
Not Acceptable
Resource
Phase 2: Rollback Manager
Discarded
Static Registration
The SonicMQ C Client resource manager uses static registration to register its participation
in each global transaction. Static registration means the transaction manager must, for
each transaction, issue the xa_start_entry, xa_end_entry, and xa_prepare_entry series
of calls to all the defined resource managers.
XA Threads
In addition to supporting the X/Open XA protocol, SonicMQ C XA transaction applications
must adhere to rules for every XA thread — each thread in which XA transactions will be
used. An XA thread:
The complete enunciation of the sample command line and its parameters is:
where:
If you have a typical local broker installation, you can let the broker and security parameters
accept their defaults. You typically specify the pTopicName and sTopicName each in
separate console windows, although they can both run concurrently. The command line
then might appear as one of the following:
When you specify both the -tp and -ts parameters, the sample acts first as a producer,
then acts as a consumer.
1. Open two console windows at the directory level of the XASample executable, typically
located adjacent to its source file.
Table 1 shows the sequence of entries in the Producer and Consumer windows.
Table 1: XASample’s Prescribed Transaction Entries
Producer Consumer
Producer Consumer
Phase 1: Prepare
Ready !
Resource
Phase 2: Commit Manager
Released
Commit Transaction
Application
Manager
Phase 1: Prepare
Ready !
Resource
Phase 2: Commit Manager
X
In this case, one branch of the global transaction committed while another branch did not.
Transaction Recovery
If the transaction owner becomes unable to continue, a transaction manager can invoke a
recovery method to a resource manager to determine the identity (xidnnn) and status of
transaction branches.
Inside SonicMQ, the TM is communicating with the SonicMQ server to let clients coordinate
with the broker. This is transparent to the application server.
The application might choose to use a container-managed transaction which means that
everything is managed by the application server.
Application Client
Application Server
Transaction Manager
SonicMQ Client
SonicMQ
Resource
xa_switch
Manager Broker
JMS Application
Transaction Manager
SonicMQ Client
SonicMQ
JMS XA SPI XA Resource Broker
JMS Application
SonicMQ Client
SonicMQ
Resource
xa_switch
Manager Broker
This model constrains the application from the benefits of distributed transaction branches.
However, for cases where two sessions, one PTP and one Pub/Sub, must coordinate in a
transaction, this model might be appropriate.
To learn more about Aurea SonicMQ and its C/C++/COM Clients, access:
• Online Books and API Documentation — You can learn about the
programming, deployment, and management of SonicMQ from its documentation
set. The SonicMQ documentation link, sonic_welcome.htm, provides links to
SonicMQ PDF books, release notes, and SonicMQ API online reference.
The SonicMQ C Client sample applications parallel the SonicMQ sample applications,
which are described in detail in Getting Started with Aurea SonicMQ and the “Examining
the SonicMQ Samples” chapter in the Aurea SonicMQ Application Programming Guide.
See Aurea Sonic Documentation on page 9 for descriptions of the SonicMQ books.
• Aurea Software Web Site — The latest SonicMQ information and downloads
are accessible by registering at [Link]/sonic.
This appendix distinguishes which SonicMQ client features are available in the Java Clients
and that are not yet available in the SonicMQ C Client.
Message Types
The JMS Java Client supports all JMS specified message types and also provides an
XMLMessage type and a MultipartMessage type. The SonicMQ C Client supports the JMS
message types TextMessage, BytesMessage, and the bodyless Message. Other types can
be handled indirectly with limitations.
XMLMessage
While not supported, XMLMessages are an extension of the TextMessage.
• Outbound, you can package XML into a TextMessage and then produce the message
to a destination where it can be picked up by an application that repackages it as an
XMLMessage. A good technique is to set the message’s header field JMSType or a
custom property that indicates that the content is XML.
MapMessage
A MapMessage is a set of strongly typed name-value pairs. You cannot access an incoming
MapMessage from the C Client. Outbound, you can either:
• Set properties for each name-value pair, and then send the message as a bodyless
Message.
• Use a BytesMessage and provide a decoding template at the start of the message that
indicates the template length and then delineates each name and value length that
can be read from the balance of the message.
Messaging Features
Some features of the SonicMQ Java Client have not been ported to other clients. If any of
these features suits your architectural needs, contact your Aurea Software representative
to learn about the feature’s scheduled implementation in the SonicMQ C Client.
For more information about recoverable file channels, see Chapter 11 of the Aurea
SonicMQ Application Programming Guide.
For more information about transacted timeouts, see Chapter 5 of the Aurea SonicMQ
Application Programming Guide.
Protocols
The TCP and SSL protocols are supported for SonicMQ C Clients.
A message move requires that a JMS client have the ability to both acknowledge receipt of
a message and forward onto a new queue in a single, atomic action that couples the send
method and the receipt acknowledge method. The session is required to use
SINGLE_MESSAGE_ACKNOWLEDGE, which is the SonicMQ non-transacted extension of the
CLIENT_ACKNOWLEDGE session parameter applies to the current message only.
For more information about acknowledge and forward, see Chapter 8 of the Aurea
SonicMQ Application Programming Guide.
For more information on duplicate detection, see Chapter 10 of the Aurea SonicMQ
Application Programming Guide.
Client Persistence
Where a network failure during a JMS send normally causes a message being sent to be
effectively lost unless the user application takes additional precautions, client persistence
enables client-based logging of messages sent until the broker connection is
re-established. This feature enhances delivery guarantees and provides disconnected
operation on Java Clients.
For more information about flow control events on the Java Client,
see Chapter 5 of the Aurea SonicMQ Application Programming Guide.
Per-message Encryption
When a Java Client application wants to ensure that it sends messages to a
security-enabled broker after encrypting them and establishing integrity tests, the
application can set the property JMS_SonicMQ_perMessageEncryption.
For more information about broker-based global subscription rules, see Chapter 9 of the
Aurea SonicMQ Application Programming Guide.
For more information about message selectors, see Chapter 7 of the Aurea SonicMQ
Application Programming Guide.
Flow To Disk
SonicMQ brokers can choose to let messages be offloaded to the database used by the
SonicMQ broker when published messages cannot be delivered immediately to a
connected yet slow subscriber. This broker functionality and the effects of flow control are
common to all SonicMQ clients. However, the SonicMQ Java client can choose to override
the broker setting to turn Flow To Disk on or off, an option that is not available to the
SonicMQ C Client.
For more information about flow to disk, see Chapter 5 of the Aurea SonicMQ Application
Programming Guide.
These common interfaces have been implemented in the SonicMQ Java client and are not
available in the SonicMQ C Client.
SonicMQ Java clients provide methods to set durable message order on the connection
factory or the session that are not supported on Sonic C Clients.
For more information about clusterwide access to durable subscriptions and strict message
order with clusterwide durable subscriptions, see Chapter 9 of the Aurea SonicMQ
Application Programming Guide.
This feature is also included as a parameter of the JMS Administered Objects Connection
Factory. See the “SonicMQ Connections” chapter in the Aurea SonicMQ Application
Programming Guide.
To override the Dead Message Queue, set the message property as follows:
HOBJ propNameDestUndelivered;
HOBJ propNameDeadQName;
HOBJ propNamePreserveUndelivered;
HOBJ propNameNotifyUndelivered;
if (String_create2(PROPERTY_NAME_SMQ_DEST_QNAME, &propNameDeadQName) != 0)
{
fprintf(stderr, "Error creating property String object\n");
handleJMSException();
}
/* Create a property string object. */
if (String_create2(PROPERTY_NAME_SMQ_PRES_UND,
&propNamePreserveUndelivered) != 0) {
fprintf(stderr, "Error creating property String object\n");
handleJMSException();
}
/* Create a property string object. */
if (String_create2(PROPERTY_NAME_SMQ_NOTIFY_UND,
&propNameNotifyUndelivered) != 0) {
fprintf(stderr, "Error creating property String object\n");
handleJMSException();
}
/* Setthe message property for the selector. */
if (TextMessage_setStringProperty(msg, propNameDestUndelivered,
propNameDeadQName) != 0) {
fprintf(stderr, "Error creating TextMessage\n");
handleJMSException();
}
if (TextMessage_setBooleanProperty(msg, propNamePreserveUndelivered,
jtrue) != 0) {
fprintf(stderr, "Error setting PRESERVE_UNDELIVERED property\n");
handleJMSException();
}
if (TextMessage_setBooleanProperty(msg, propNameNotifyUndelivered, jtrue)
!= 0) {
fprintf(stderr, "Error setting PRESERVE_UNDELIVERED property\n");
handleJMSException();
}
For more information, see the “Guaranteeing Messages” chapter in the Aurea SonicMQ
Application Programming Guide and the “Configuring Queues” chapter in the Aurea
SonicMQ Configuration and Management Guide.
For more information about the management and metrics APIs, see the appendices
of the Aurea SonicMQ Administrative Programming Guide.
For more information about the management framework, see the Aurea SonicMQ
Configuration and Management Guide.
CLIENT_ACKNOWLEDGE 72
acknowledge and forward 25
clients
acknowledgement 23
identifier 67
automatic 23
client 23 commit
Dups_OK 23 definition 23
lazy 23 in a global transaction 106, 107
single message 23
concurrency 22
administered objects
ConnectionFactories 65 ConnectionFactories
definition 65
asynchronous 24
connections 21
authentication fault-tolerant 76
SSL identifier 66
client certificates 101
username and password 100 connections, creating 68
automatic acknowledgement 23 consumers 24
Continuous Availability
B client connection 76
creating, sessions 68
C
callback functions 59 D
characters, restricted 63 dead message queue 27, 33
durable subscribers
definition 30 J
durable subscription JMS
sample application 46 provider 15
DurableChat sample application 46
message servers
F topology 14
message types 31
fault tolerant client 76
Message_gettype 57
fault-tolerant connections 76
Message_instanceof 57
Figure 1
Distributed Application Structure 14 messages
body 32
forwarding 25 header fields 32
properties 32
H
N
header files 56
non-persistent 25
hierarchical name spaces
definition 31
HierarchicalChat sample application 47, 48 P
HOBJs 56 persistent 25
delivery mode 30
HOBJs,releasing 60 message 33
hostname 66 persistent message delivery 72
point-to-point 25
I
Point-to-Point sample applications 41
identifier
port 66
client 67
connection 66 prefetch 26
indoubt privacy 34
producers 24 SMQ_getLastError 61
properties 32 SMQ_getLastErrorText 61
protocols 66 smqc.h 56
publishers 30 SSL 97
starting, connection 70
Q store and forward 25
quality of protection 33 strings 57
quality of service 32 subscribers 30
queues support, technical 11
browser 28
definition 25 synchronous 24
R T
receivers 27 Talk sample application 42
release method 60 technical support 11
ReliableChat sample application 49 temporary destination 32
ReliableTalk sample application 43 TextMessage type 31
request and reply 23, 32 topic hierarchies 31
RequestReply sample application 51 topics 25
resource transacted sessions
enlistment 105 definition 22
rollback transaction
definition 23 context 105
transaction manager 104
S
transactions
security store global 23
external 92 local 23
internal 92 timeout 23
senders 27
U
sending, message 70
URL 66
sessions 21
username 67
sessions, creating 68