#import "SdtPubSubMsgIndepExample.h"
@implementation SdtPubSubMsgIndepExample
- (id)initWithExampleInterface:(ExampleInterface *)exampleInterface {
self = [super initWithExampleInterface:exampleInterface];
self.name = @"SdtPubSubMsgIndep";
self.description =
@"Demonstrates how to publish SDT map messages to a topic "
@"(independent of a Solace message)";
return self;
}
- (void)run {
[super run];
int msgsSent = 0;
char stream[1024];
char map[1024];
char messageField[32];
[self handleErrorWithReturnCode:rc
errorString:"solClient_initialize()"];
goto notInitialized;
}
[self setLoggingLevel];
"(Copyright 2009-2024 Solace Corporation. All rights reserved.)\n");
[self logCCSMPVersion];
&contextFuncInfo,
sizeof(contextFuncInfo))) !=
SOLCLIENT_OK) {
[self handleErrorWithReturnCode:rc
errorString:"solClient_context_create()"];
goto cleanup;
}
if ((rc = [self
createAndConnectSessionWithContext:context_p
session:&session_p
messageCallback:messageReceivePrintMsgCallback
eventCallback:eventCallback]) !=
[self handleErrorWithReturnCode:
rc errorString:"createAndConnectSessionWithContext:session:"
"messageCallback:eventCallback:userData:"];
goto cleanup;
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_topicSubscribe()"];
goto sessionConnected;
}
&streamContainer, stream,
sizeof(stream))) !=
SOLCLIENT_OK) {
[self handleErrorWithReturnCode:rc
errorString:"solClient_container_createStream()"];
goto sessionConnected;
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_container_addDouble()"];
goto freeContainer;
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_container_addString()"];
goto freeContainer;
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_container_createMap()"];
goto sessionConnected;
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_container_addInt32()"];
goto freeContainer;
}
[self handleErrorWithReturnCode:rc errorString:"solClient_msg_alloc()"];
goto freeContainer;
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_msg_setDeliveryMode()"];
goto freeMessage;
}
destination.
dest = COMMON_MY_SAMPLE_TOPIC;
msg_p, &destination,
sizeof(destination))) !=
SOLCLIENT_OK) {
[self handleErrorWithReturnCode:rc
errorString:"solClient_msg_setDestination()"];
goto freeMessage;
}
for (msgsSent = 0;
msgsSent < 10 &&
!self.requestCancel;
++msgsSent) {
[self
handleErrorWithReturnCode:rc
errorString:"solClient_container_deleteField()"];
goto freeMessage;
}
snprintf(messageField, 32, "message%d", (msgsSent + 1));
[self handleErrorWithReturnCode:rc
errorString:"solClient_container_addString()"];
goto freeMessage;
}
[self handleErrorWithReturnCode:
rc errorString:
"solClient_msg_setBinaryAttachmentContainer()"];
goto freeMessage;
}
[self
handleErrorWithReturnCode:rc
errorString:"solClient_msg_setUserPropertyMap()"];
goto freeMessage;
}
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_sendMsg()"];
goto freeMessage;
}
}
freeMessage:
[self handleErrorWithReturnCode:rc errorString:"solClient_msg_free()"];
goto sessionConnected;
}
freeContainer:
[NSThread sleepForTimeInterval:1];
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_topicSubscribe()"];
goto sessionConnected;
}
sessionConnected:
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_disconnect()"];
}
cleanup:
[self handleErrorWithReturnCode:rc errorString:"solClient_cleanup()"];
}
notInitialized:
[self cleanup];
}
@end