#import "SyncCacheRequestExample.h"
@implementation SyncCacheRequestExample
- (id)initWithExampleInterface:(ExampleInterface *)exampleInterface {
self = [super initWithExampleInterface:exampleInterface];
self.name = @"SyncCacheRequest";
self.description = @"Demonstrates how to send a synchronous cache request";
[self.parameters addParameter:PARAMETER_CACHE_NAME];
[self.parameters addParameter:PARAMETER_DESTINATION_TOPIC];
return self;
}
- (void)run {
[super run];
const char *cacheProps[20];
int propIndex = 0;
[self handleErrorWithReturnCode:rc
errorString:"solClient_initialize()"];
goto notInitialized;
}
[self setLoggingLevel];
"SyncCacheRequestExample.m (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;
}
if ((rc = [self
publishMessageWithSession:
session_p topic:(char *)
[[self.parameters
parameterWithId:PARAMETER_DESTINATION_TOPIC]
.value
cStringUsingEncoding:NSASCIIStringEncoding]
[self handleErrorWithReturnCode:rc
errorString:"common_publishMessage()"];
goto sessionConnected;
}
propIndex = 0;
cacheProps[propIndex++] =
[[self.parameters parameterWithId:PARAMETER_CACHE_NAME].value
cStringUsingEncoding:NSASCIIStringEncoding];
cacheProps[propIndex] = NULL;
(const char *const *)cacheProps, session_p, &cacheSession_p)) !=
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_createCacheSession"];
goto sessionConnected;
}
cacheSession_p,
[[self.parameters parameterWithId:PARAMETER_DESTINATION_TOPIC]
.value cStringUsingEncoding:NSASCIIStringEncoding],
cacheRequestId, NULL, NULL, cacheFlags, 0)) !=
SOLCLIENT_OK) {
[self handleErrorWithReturnCode:
rc errorString:"solClient_cacheSession_sendCacheRequest()"];
goto cleanupCache;
}
cleanupCache:
[self handleErrorWithReturnCode:rc
errorString:"solClient_cacheSession_destroy()"];
}
sessionConnected:
[self handleErrorWithReturnCode:rc
errorString:"solClient_session_disconnect()"];
}
cleanup:
[self handleErrorWithReturnCode:rc errorString:"solClient_cleanup()"];
}
notInitialized:
[self cleanup];
}
@end