Use a função cciGetBrokerInfo para consultar o ambiente do broker atual (por exemplo, para obter informações sobre o nome do broker, o nome do grupo de execução, o nome do gerenciador de filas). As informações são retornadas em uma estrutura do tipo CCI_BROKER_INFO_ST.
Esta função difere de cniGetBrokerInfo visto que você não precisa especificar um identificador CciNode* e que ela não retorna informações sobre um fluxo de mensagens. Portanto, é possível chamar cciGetBrokerInfo a partir de funções de inicialização; por exemplo, bipInitializeUserExits, bipGetMessageParserFactory e bipGetMessageFlowNodeFactory.
void cciGetBrokerInfo(
int* returnCode,
CCI_BROKER_INFO_ST* broker_info_st);
typedef struct cci_broker_info_st {
int versionId; /*Identificação de versão da estrutura*/
CCI_STRING_ST brokerName; /*O rótulo do broker*/
CCI_STRING_ST executionGroupName; /*O rótulo do grupo de execução atual*/
CCI_STRING_ST queueManagerName; /*O nome do MQ Queue Manager para o broker*/
CCI_STRING_ST dataSourceUserId; /*O broker userid é conectado a datasource como*/
} CCI_BROKER_INFO_ST;
Nenhum Se ocorrer um erro, o parâmetro returnCode indica o motivo do erro.
int rc = CCI_SUCCESS;
CCI_BROKER_INFO_ST brokerInfo = {CCI_BROKER_INFO_ST_DEFAULT};
#definir INTITIAL_STR_LEN 256
CciChar brokerNameStr[INTITIAL_STR_LEN];
CciChar executionGroupNameStr[INTITIAL_STR_LEN];
CciChar queueManagerNameStr[INTITIAL_STR_LEN];
brokerInfo.brokerName.bufferLength = INTITIAL_STR_LEN;
brokerInfo.brokerName.buffer = brokerNameStr;
brokerInfo.executionGroupName.bufferLength = INTITIAL_STR_LEN;
brokerInfo.executionGroupName.buffer = executionGroupNameStr;
brokerInfo.queueManagerName.bufferLength = INTITIAL_STR_LEN;
brokerInfo.queueManagerName.buffer = queueManagerNameStr;
cciGetBrokerInfo(&rc,&brokerInfo);
/* apenas no caso de algum dos buffers ser muito pequeno*/
if ((brokerInfo.brokerName.bytesOutput < brokerInfo.brokerName.dataLength) ||
(brokerInfo.executionGroupName.bytesOutput < brokerInfo.executionGroupName.dataLength) ||
(brokerInfo.queueManagerName.bytesOutput < brokerInfo.queueManagerName.dataLength)) {
/*pelo menos um dos buffers eram muito pequenos, tente novamente*/
/* NOTA: É improvável que os tamanhos iniciais eram razoavelmente grandes*/
brokerInfo.brokerName.bufferLength =
brokerInfo.brokerName.dataLength;
brokerInfo.brokerName.buffer =
(CciChar*)malloc (brokerInfo.brokerName.bufferLength * sizeof(CciChar));
brokerInfo.executionGroupName.bufferLength =
brokerInfo.executionGroupName.dataLength;
brokerInfo.executionGroupName.buffer =
(CciChar*)malloc (brokerInfo.executionGroupName.bufferLength * sizeof(CciChar));
brokerInfo.queueManagerName.bufferLength =
brokerInfo.queueManagerName.dataLength;
brokerInfo.queueManagerName.buffer =
(CciChar*)malloc (brokerInfo.queueManagerName.bufferLength * sizeof(CciChar));
cciGetBrokerInfo(&rc,&brokerInfo);
/*agora faça algo que tenha sentido com essas cadeias antes de os buffers ficarem fora do escopo*/
/* por exemplo, chame uma função gravada do usuário para copiá-las para outro local*/
copyBrokerInfo(brokerInfo.brokerName.buffer,
brokerInfo.executionGroupName.buffer,
brokerInfo.queueManagerName.buffer);
free((void*)brokerInfo.brokerName.buffer);
free((void*)brokerInfo.executionGroupName.buffer);
free((void*)brokerInfo.queueManagerName.buffer);
}else{
/*agora faça algo que tenha sentido com essas cadeias antes de os buffers ficarem fora do escopo*/
/* por exemplo, chame uma função gravada do usuário para copiá-las para outro local*/
copyBrokerInfo(brokerInfo.brokerName.buffer,
brokerInfo.executionGroupName.buffer,
brokerInfo.queueManagerName.buffer);
}