mirror of https://github.com/apache/activemq.git
AMQ-874 - updating example on the wiki for basic activemq-cpp usage
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@431268 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b84c864d85
commit
f012622ff4
|
@ -0,0 +1,205 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8.00"
|
||||
Name="examples"
|
||||
ProjectGUID="{5830D72A-1239-45B7-B94E-04153B2D4EA4}"
|
||||
RootNamespace="examples"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories=""D:\Program Files\Microsoft Platform SDK\Include";"E:\Eclipse\ActiveMQ\activemq-cpp\src\main";"E:\dev\cppunit-1.11.6\include";"E:\Eclipse\ActiveMQ\activemq-cpp\src\test""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="2"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="activemq-cpp.lib ws2_32.lib cppunitd.lib rpcrt4.lib"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""E:\dev\cppunit-1.11.6\lib";"D:\Program Files\Microsoft Platform SDK\Lib";"E:\Eclipse\ActiveMQ\activemq-cpp\src\main\Debug""
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="kernel32.lib $(NoInherit)"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\main.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\ReadMe.txt"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -49,14 +49,14 @@ public:
|
|||
connection->start();
|
||||
|
||||
// Create a Session
|
||||
session = connection->createSession( Session::AutoAcknowledge );
|
||||
session = connection->createSession( Session::AUTO_ACKNOWLEDGE );
|
||||
|
||||
// Create the destination (Topic or Queue)
|
||||
destination = session->createQueue("TEST.FOO");
|
||||
destination = session->createQueue( "TEST.FOO" );
|
||||
|
||||
// Create a MessageProducer from the Session to the Topic or Queue
|
||||
producer = session->createProducer(*destination);
|
||||
producer->setDeliveryMode( Message::NONPERSISTANT);
|
||||
producer = session->createProducer( destination );
|
||||
producer->setDeliveryMode( DeliveryMode::NON_PERSISTANT );
|
||||
|
||||
// Stringify the thread id
|
||||
char threadIdStr[100];
|
||||
|
@ -70,12 +70,12 @@ public:
|
|||
|
||||
// Tell the producer to send the message
|
||||
printf( "Sent message from thread %s\n", threadIdStr );
|
||||
producer->send(*message);
|
||||
producer->send( message );
|
||||
|
||||
delete message;
|
||||
}
|
||||
|
||||
}catch (CMSException& e) {
|
||||
}catch ( CMSException& e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -84,31 +84,31 @@ private:
|
|||
|
||||
void cleanup(){
|
||||
|
||||
// Close open resources.
|
||||
try{
|
||||
if( session != NULL ) session->close();
|
||||
if( connection != NULL ) connection->close();
|
||||
}catch (CMSException& e) {}
|
||||
|
||||
// Destroy resources.
|
||||
try{
|
||||
if( destination != NULL ) delete destination;
|
||||
}catch (CMSException& e) {}
|
||||
}catch ( CMSException& e ) {}
|
||||
destination = NULL;
|
||||
|
||||
try{
|
||||
if( producer != NULL ) delete producer;
|
||||
}catch (CMSException& e) {}
|
||||
}catch ( CMSException& e ) {}
|
||||
producer = NULL;
|
||||
|
||||
// Close open resources.
|
||||
try{
|
||||
if( session != NULL ) session->close();
|
||||
if( connection != NULL ) connection->close();
|
||||
}catch ( CMSException& e ) {}
|
||||
|
||||
try{
|
||||
if( session != NULL ) delete session;
|
||||
}catch (CMSException& e) {}
|
||||
}catch ( CMSException& e ) {}
|
||||
session = NULL;
|
||||
|
||||
try{
|
||||
try{
|
||||
if( connection != NULL ) delete connection;
|
||||
}catch (CMSException& e) {}
|
||||
}catch ( CMSException& e ) {}
|
||||
connection = NULL;
|
||||
}
|
||||
};
|
||||
|
@ -143,7 +143,8 @@ public:
|
|||
try {
|
||||
|
||||
// Create a ConnectionFactory
|
||||
ActiveMQConnectionFactory* connectionFactory = new ActiveMQConnectionFactory("tcp://127.0.0.1:61613");
|
||||
ActiveMQConnectionFactory* connectionFactory =
|
||||
new ActiveMQConnectionFactory( "tcp://127.0.0.1:61613" );
|
||||
|
||||
// Create a Connection
|
||||
connection = connectionFactory->createConnection();
|
||||
|
@ -153,13 +154,13 @@ public:
|
|||
connection->setExceptionListener(this);
|
||||
|
||||
// Create a Session
|
||||
session = connection->createSession( Session::AutoAcknowledge );
|
||||
session = connection->createSession( Session::AUTO_ACKNOWLEDGE );
|
||||
|
||||
// Create the destination (Topic or Queue)
|
||||
destination = session->createQueue("TEST.FOO");
|
||||
destination = session->createQueue( "TEST.FOO" );
|
||||
|
||||
// Create a MessageConsumer from the Session to the Topic or Queue
|
||||
consumer = session->createConsumer(*destination);
|
||||
consumer = session->createConsumer( destination );
|
||||
|
||||
consumer->setMessageListener( this );
|
||||
|
||||
|
@ -171,17 +172,16 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual void onMessage( const Message& message ){
|
||||
virtual void onMessage( const Message* message ){
|
||||
|
||||
try
|
||||
{
|
||||
const TextMessage& textMessage = dynamic_cast<const TextMessage&>(message);
|
||||
string text = textMessage.getText();
|
||||
const TextMessage* textMessage =
|
||||
dynamic_cast< const TextMessage* >( message );
|
||||
string text = textMessage->getText();
|
||||
printf( "Received: %s\n", text.c_str() );
|
||||
}
|
||||
catch( std::bad_cast& ex )
|
||||
{
|
||||
printf( "Received something other than a text Message\n" );
|
||||
} catch (CMSException& e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,12 +193,6 @@ private:
|
|||
|
||||
void cleanup(){
|
||||
|
||||
// Close open resources.
|
||||
try{
|
||||
if( session != NULL ) session->close();
|
||||
if( connection != NULL ) connection->close();
|
||||
}catch (CMSException& e) {}
|
||||
|
||||
// Destroy resources.
|
||||
try{
|
||||
if( destination != NULL ) delete destination;
|
||||
|
@ -210,7 +204,13 @@ private:
|
|||
}catch (CMSException& e) {}
|
||||
consumer = NULL;
|
||||
|
||||
// Close open resources.
|
||||
try{
|
||||
if( session != NULL ) session->close();
|
||||
if( connection != NULL ) connection->close();
|
||||
}catch (CMSException& e) {}
|
||||
|
||||
try{
|
||||
if( session != NULL ) delete session;
|
||||
}catch (CMSException& e) {}
|
||||
session = NULL;
|
||||
|
|
Loading…
Reference in New Issue