Gemfire get the error from cqEvent - c++

I have a registered cqListener on a region. How can i get the actual error why onError had occured from the parameter of the method const gemfire::CqEvent& cqEvent?
I checked the documentation but it seems they don't have any method on the CqEvent class that can acctually retrieve a possible error.

#Alex
Hi Alex,
See what documentation says:
/**
* This method is invoked when there is an error during CQ processing.
* The error can appear while applying query condition on the event.
* e.g if the event doesn't has attributes as specified in the CQ query.
* This event does contain an error. The newValue may or may not be
* available, and will be NULLPTR if not available.
*/
virtual void onError(const CqEvent& aCqEvent);
It explicitly mentions "This event does contain an error". and CqEvent also does not contain method to get the error.

Related

Opencart 3.0.3.7 event not catch, not working

Note: I had read tons of information here and another sources, including official docs.
I have a payment extension - ex title simplepay.
I want to know specifically if it is a way to "listen" to a system (predefined) event.
I want to run some logic when an order status has changed.
In the admin/controller/extension/payment/simplepay.php I have this (nothing more elsewhere):
public function install()
{
$this->load->model('setting/event');
/** addEvent($code, $trigger, $action, $status = 1, $sort_order = 0); */
$this->model_setting_event->addEvent(
'do_transaction_on_order_status_change',
'catalog/controller/api/order/history/after',
'extension/payment/simplepay/doTransactionOnOrderStatusChange');
}
public function uninstall()
{
$this->load->model('setting/event');
/** deleteEventByCode($code); */
$this->model_setting_event->deleteEventByCode('do_transaction_on_order_status_change');
}
public function doTransactionOnOrderStatusChange(&$route, &$data)
{
// testing purpose for the moment
$log = new Log('aaaaaa.log');
$log->write('Route ' . $route);
}
The event do_transaction_on_order_status_change is properly registered in events list.
What I am doing wrong?
Nevermind!
After a while I got the point.
My method doTransactionOnOrderStatusChange(&$route, &$data) was writted with 3 parameters.
Like doTransactionOnOrderStatusChange(&$route, &$data, &$output).
The problem is that OC 3+ not accept a third parameter, even if there is a "before" or an "after" event.
And another problem was the related event: it must be admin/controller/sale/order/history/before. (or /after)
No other event on order change worked. (probably this event is the only admin event, the rest being from catalog).
Later edit
The above works only for trigger the method, but had nonsense to do what was supposed to.
So, after other research time, it was obvious that the event I need to listen to was: catalog/controller/api/order/history/after. (an event raised from admin, but from catalog, weird!!).
To listen to that event, was need to make another controller in catalog/controller/extension/payment/simplepay.php then put that method (doTransactionOnOrderStatusChange) inside it.
Note that my question contains the proper event.
I hope someone will find this helpful!

TYPO3 Webservice/Rest API as Repository for Extbase Extension

I am developing an TYPO3 extbase extension to connect to my external application that has a REST-API. All I want is to retrieve the data from my REST-API and pass this data to the controller. Since I am quite new to extbase development, I didn't really find any resources about Repository interacting with a webservice. Only documentation about Repository that interacts with a database (MySQL, PostgreSQL, ..)
I would like to know, where should I place the cURL-Request Function to connect to the API? In the Model? In the Repository? How can the Controller in my Extension access that data? From Model or Repository?
What would be the best practice for retrieving the data from my external application/database ? (the data retrieved from the application is JSON-formatted)
thanks for any advice / help!
What we usually do is create a Service (in Classes/Service) and use that to connect to the webservice and fetch the data. If you want Models, you can create them there as well.
However, now that I think about it, technically it should be a Repository. It shouldn't matter where the Repository gets its data. Extbase shouldn't have any problem with a completely custom Repository (not extending any other class).
Lets take a simple list -> detail view and make it as simple as possible in order to get some results. Then you can add some helper classes and include them via namespaces etc.
ListAction (yourExtension/Classes/Controller/EventController)
/**
* action list
*
* #return void
*/
public function listAction()
{
$events = (some function which gets all the available events and results to a json output)
$decodedEvents = json_decode($events , true);
(in case you need to see what you got back)
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($decodedEvents);
$this->view->assign('events', $decodedEvents);
}
List HTML (yourExtension/Resources/Private/Templates/Event/List)
<f:for each="{events}" as="event">
<h2>{event.title}</h2>
</for>
Now if i am not wrong, every event has a uid or something that identifies it. So on the same template you can do the following:
<f:for each="{events}" as="event">
<h2>{event.title}</h2>
<f:link.action action="detail" arguments="{eventId: event.uid}">More</f:link.action>
</f:for>
What this does, is to generate a link which links to your detail action with an extra parameter, the eventId.
Bedore TYPO3 renders the detail page it will go through your detail action to get the information for this specific event in order to display them.
DetailAction (yourExtension/Classes/Controller/EventController)
/**
* action detail
*
* #return void
*/
public function detailAction()
{
$args = $this-request->getArguments();
$eventId = $args['eventId'];
$getEvent = (some function that gets a specific id and results to a json output)
$decodedEvent = json_decode($getEvent , true);
(in case you need to see what you got back)
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($decodedEvent );
$this->view->assign('event', $decodedEvent );
}
What this does, it to retrieve the argument that we specified in order to get the identifier of the event and include it on your api request to get the event back. Then we just just decode it to a normal array and we send the results to the FrontEnd.
Detail HTML (yourExtension/Resources/Private/Templates/Event/Detail)
<h2>{event.title}</h2>
Thats a simple list -> detail proccess on TYPO3. You will oft see that the detail view as show but is basically the same thing.
You can replace the variables with a dummy json values and play around. I tested the code while i was writing this answer and it works.
Classes/Service
As for the Classes/Service that mentioned by Rudy Gnodde, you can put your library in there (assuming that you already have coded some functions like getEvent, getAllEvents, getPersons etc.) and then call them in the controller.
use \Vendor\YourExtension\Service\RestApiClass;
/**
* action list
*
* #return void
*/
public function listAction()
{
$events = RestApiClass::getAllEvents();
$decodedEvents = json_decode($events , true);
(in case you need to see what you got back)
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($decodedEvents);
$this->view->assign('events', $decodedEvents);
}
/**
* action detail
*
* #return void
*/
public function detailAction()
{
$args = $this-request->getArguments();
$eventId = $args['eventId'];
$getEvent = RestApiClass::getEvents($eventId);
$decodedEvent = json_decode($getEvent , true);
(in case you need to see what you got back)
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($decodedEvent );
$this->view->assign('event', $decodedEvent );
}
If you need more information feel free to ask.
Best regards

Checking for duplicates in VEINS

I am new to Veins and trying to implement a mechanism to detect if the WSM packet was received before. I am using the "psid" as the main variable to identify the packet - is it correct?
Will this type of code work? :
bool MyVeinsApp::msgReceivedBefore(int psid){
/*
This function will be used to determine if the message was received before
and should be discarded or processed further
*/
if(msg_log.find(psid) == msg_log.end()){
return false
}
else {
return true;
}
}
Here msg.log is a C++ data structure storing WSMs based on psid.
The psid only is an identifier for the service you are using (see WaveShortMessage.msg) and therefore not unique among messages of the same service. To distinguish between messages you need a unique message identifier.
A simple approach would be to use the id which every module in OMNeT++ gets:
msg->getId()
UPDATE: Please note that this id also is unique among all messages with the same content (see comment down below).

Create Azure EventHub Message in Azure Functions

I'm trying to do some Proof of Concept with EventHub and Azure Functions. I have a Generic Webhook Function in C# that I want to pass a message to my EventHub.
I get stuck on the parameter name given on the "Integrate" tab. If I declare that name among the parameters I have to give it a type. I can't figure out what kind of type though... I've tried:
String (other functions uses that together with the direction, not applicable with webhooks).
EventData
IEnumerable
I can't get it to work. If I don't do this I get the error message:
"Missing binding argument named 'outputEventHubMessage'"
If I give it the wrong type I get the message:
"Error indexing method 'Functions.GenericWebhookCSharp1'. Microsoft.Azure.WebJobs.Host: Can't bind to parameter."
I'm probably a bit lost in documentation or just a bit tired, but I'd appreciate any help here!
/Joakim
Likely you're just missing the out keyword on your parameter. Below is a working WebHook function that declares an out string message parameter that is mapped to the EventHub output, and writes an EventHub message via message = "Test Message".
Because async functions can't return out parameters, I made this function synchronous (returning an object rather than Task<object>). If you want to remain async, rather than use an out parameter, you can instead bind to an IAsyncCollector<string> parameter. You can then enqueue one or more messages by calling the AddAsync method on the collector.
More details on the EventHub binding and the types it supports can be found here. Note that the other bindings follow the same general patterns.
#r "Newtonsoft.Json"
using System;
using System.Net;
using Newtonsoft.Json;
public static object Run(HttpRequestMessage req, out string message, TraceWriter log)
{
string jsonContent = req.Content.ReadAsStringAsync().Result;
dynamic data = JsonConvert.DeserializeObject(jsonContent);
log.Info($"Webhook was triggered! Name = {data.first}");
message = "Test Message";
var res = req.CreateResponse(HttpStatusCode.OK, new {
greeting = $"Hello {data.first} {data.last}!"
});
return res;
}

Usage of send and receive task in camunda BPMN

I am using a send task to which the following Javadelegate class is attached.
public class SendTaskDelegate implements JavaDelegate {
public void execute(DelegateExecution execution) throws Exception {
execution.getProcessEngineServices()
.getRuntimeService()
.createMessageCorrelation("someMessage")
.processInstanceBusinessKey("someBusinessKey")
.correlate();
}
}
But I am getting this error::
An error happend while submitting the task form : Cannot submit task form c0e85bad-719f-11e5-94aa-d897baecf24a: Cannot correlate message someMessage: No process definition or execution matches the parameters
How can I debug it?
The error message says, that your JavaDelegate code just gets excuted correctly. The process engine tries to find a running process instance with 'someBusinessKey' as business key and currently waiting for a message 'someMessage', but does not find such an instance. Your code acts as if there were such an instance and you try to find it and tell it about a message. See the docs section about correlation methods - in principle the mechanism is used to 'route' a message to the correct instance targeting it.
As a sidenote: your JavaDelegate seems to get called in the same transaction with which you also try to complete a task. The "borders of transactions" in your process can be managed with 'async' attributes described in the docs section about transactions in processes.