My question is can we go back to middle ware pipeline let see an example
we have middleware1, middlware2, middleware3 and middlware3 is executing. I want middleware1 to execute again and then control back to middleware3 can we do that ?
Thank in advance
No, you cannot do that. The middlewares are called in a pipeline. That means, there is one middleware which will start and which will pass on to the next middleware in the pipeline, which will then pass on to the next, and so on. Eventually, each middleware has a way to do something afterwards as the pipeline completes.
This generally looks like this:
Request
| → Middleware1
| | run
| | next() → Middleware2
| | | run
| | | next() → Middleware3
| | | | run
| | | | next() → {}
| | | | run after
| | | | return ↵
| | | ←
| | | run after
| | | return ↵
| | ←
| | run after
| | return ↵
| ←
| ⇒ Send response
Since this is a strict pipeline that only goes in a single direction, you cannot randomly jump around. You only get the chance to call the next middleware in the pipeline or return.
What you can do however is invoke the following pipeline multiple times. For example, the StatusCodePages middleware does this to re-execute the pipeline for the status code page when an error occurs:
Request
| → StatusCodePagesMiddleware
| | run
| | next() → Pipeline
| | | … throw an error
| | ← catch exception
| | run after
| | adjust parameters
| | next() → Run pipeline again with modified parameters do display error page
| | return ↵
| ←
| ⇒ Send response
Note that this is a very special thing which only works because the StatusCodePages middleware is usually registered very early and because it wants to rerun the full pipeline.
If you want finer control over this, chances are you shouldn’t even split your logic up into multiple middlewares. It might be a better idea to have a single middleware that just has a very controlled logic inside. That logic could for example be another pipeline, or just a straightforward control flow.
Related
We are intending to build up a one way network of exchange-to-exchange bindings. Our requirement is to attach the route a message took to its header, but there seems to be no way to find out which exchange handled a message last.
I already tried looking up the information using the tracing functionality and there also exists a plugin that subscribes to the internal basic.publish event. Yet, all these ways just give me the exchange of first entry.
I even took a look at the rabbitmq-server source code and it seems like there is no possible extension point inside the routing function (see headers exchange routing for example). I am not an Erlang dev, so maybe there is an Erlang way of intercepting/extending functions to be called?
Example
+---------+
| |
| POE |
| |
+--+--+---+
| |
+-------+ | | +-------+
| | | | | |
| EX1 +---+ +----+ EX2 |
| | | |
+--+----+ +---+---+
| |
| |
| |
+--+----+ +---+---+
| | | |
| QU1 | | QU2 |
| | | |
+-------+ +-------+
For a message that ends up in QU2 we would like to have a header field like this:
{...
x-route, ["POE", "EX2"]
}
This could probably be accomplished with a RabbitMQ plugin but it would be difficult to do: a channel interceptor would have to effectively do a part of the routing to determine the "last" exchange. There could be more than one "last" exchange, as well.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.
I'm trying to pass Data from a table into a feature file and then finally onto my java script step-definitions, shown below.
Scenario: XX | Basket Tests: Cover Type | Building + no bundle + HE
Given I open the page with the url "http://localhost:3000" and route "/basket"
When I click the button <coverTypeID>
And I click the button <bundleID>
Then I see the result <expectedResult>
| id | url | coverTypeID | bundleID | elementID | expectedResult |
| 1 | http://localhost:3000/basket | coverTypeId101 | NoBundle | null | |
| 2 | http://localhost:3000/basket | coverTypeId101 | NoBundle | checkbox1 | |
| 3 | http://localhost:3000/basket | coverTypeId101 | NoBundle | checkbox2 | |
| 4 | http://localhost:3000/basket | coverTypeId101 | NoBundle | checkbox3 | |
| 5 | http://localhost:3000/basket | coverTypeId101 | NoBundle | checkbox4 | |
Is my Feature file, i used to pass data using strings however now i am using the data table it doesn't identify the scenario when the tests run.
When("I click the button <coverTypeID>", (buttonID, next) => {
driver.findElement(By.id(buttonID)).then(pageElement => { /////////////////////////////////////////////
driver.wait(until.elementIsVisible(pageElement), 10000).then(async () => { //This is to click a button using elementID//
await driver.sleep(3000); /////////////////////////////////////////////
pageElement.click();
next();
})
.catch(ex => {
console.log(ex.message, ex.stack)
});
}).catch(ex => {console.log(ex.message, ex.stack)});
});
The error i'm getting is that the tests are undefined as the scenario doesn't match the step definition properly because of the usage of the table titles
I've looked at using Regular Expressions however i'm not sure what type of data the data table passes when executing, any guidance would be of use, i've went through a bunch of different questions and none quite seem to answer mine.
Any help would be greatly appreciated, i'd like to avoid regular expression if i could because the aim is to make the code as readable as possible.
Thank you in advance.
so i found the solution, rather than expecting the title of the data table i referred back to using {string}
When("I click the button {string}", (buttonID, next) => {
Then in the data table i realised the mistake i was making was simply not adding quotation marks to make the data into string format.
Examples:
| id | coverTypeID | bundleID | elementID |
| 1 | "coverTypeId101" | "moreDetails1" | "checkbox2" |
By doing this the feature now sucessfully pulls data from the feature file into the JS file.
In my Fitnesse Tests I want to enter dates through datepicker elements. Sometimes it works. But most of the time a different date, unlike the date that was entered, appears. Here is an example:
| ensure | do | type | on | id=field_id | with | |
| ensure | do | type | on | id=field_id | with | 05.05.1997 |
| check | is | verifyValue | on | id=field_id | [28.05.1997] expected [05.05.1997] |
(To make sure that the field isn't already filled, I pass an empty String first.)
Mostly, the 'day'-statement is different from what was entered. Do you know the reason for this behavior? How can I solve this?
Thanks in advance!
This is related to how you wrote your fixture and not FitNesse, the problem is that it returns a different value and also implies that the previous line didn't work - | ensure | do | type | on | id=field_id | with | 05.05.1997 |
I have reworked our API's logging system to use Azure Table Storage from using SQL storage for cost and performance reasons. I am now migrating our legacy logs to the new system. I am building a SQL query per table that will map the old fields to the new ones, with the intention of exporting to CSV then importing into Azure.
So far, so good. However, one artifact of the previous system is that it logged 3 times per request - call begin, call response and call end - and the new one logs the call as just one log (again, for cost and performance reasons).
Some fields common are common to all three related logs, e.g. the Session which uniquely identifies the call.
Some fields I only want the first log's value, e.g. Date which may be a few seconds different in the second and third log.
Some fields are shared for the three different purposes, e.g. Parameters gives the Input Model for Call Begin, Output Model for Call Response, and HTTP response (e.g. OK) for Call End.
Some fields are unused for two of the purposes, e.g. ExecutionTime is -1 for Call Begin and Call Response, and a value in ms for Call End.
How can I "roll up" the sets of 3 rows into one row per set? I have tried using DISTINCT and GROUP BY, but the fact that some of the information collides is making it very difficult. I apologize that my SQL isn't really good enough to really explain what I'm asking for - so perhaps an example will make it clearer:
Example of what I have:
SQL:
SELECT * FROM [dbo].[Log]
Results:
+---------+---------------------+-------+------------+---------------+---------------+-----------------+--+
| Session | Date | Level | Context | Message | ExecutionTime | Parameters | |
+---------+---------------------+-------+------------+---------------+---------------+-----------------+--+
| 84248B7 | 2014-07-20 19:16:15 | INFO | GET v1/abc | Call Begin | -1 | {"Input":"xx"} | |
| 84248B7 | 2014-07-20 19:16:15 | INFO | GET v1/abc | Call Response | -1 | {"Output":"yy"} | |
| 84248B7 | 2014-07-20 19:16:15 | INFO | GET v1/abc | Call End | 123 | OK | |
| F76BCBB | 2014-07-20 19:16:17 | ERROR | GET v1/def | Call Begin | -1 | {"Input":"ww"} | |
| F76BCBB | 2014-07-20 19:16:18 | ERROR | GET v1/def | Call Response | -1 | {"Output":"vv"} | |
| F76BCBB | 2014-07-20 19:16:18 | ERROR | GET v1/def | Call End | 456 | BadRequest | |
+---------+---------------------+-------+------------+---------------+---------------+-----------------+--+
Example of what I want:
SQL:
[Need to write this query]
Results:
+---------------------+-------+------------+----------+---------------+----------------+-----------------+--------------+
| Date | Level | Context | Message | ExecutionTime | InputModel | OutputModel | HttpResponse |
+---------------------+-------+------------+----------+---------------+----------------+-----------------+--------------+
| 2014-07-20 19:16:15 | INFO | GET v1/abc | Api Call | 123 | {"Input":"xx"} | {"Output":"yy"} | OK |
| 2014-07-20 19:16:17 | ERROR | GET v1/def | Api Call | 456 | {"Input":"ww"} | {"Output":"vv"} | BadRequest |
+---------------------+-------+------------+----------+---------------+----------------+-----------------+--------------+
select L1.Session, L1.Date, L1.Level, L1.Context, 'Api Call' AS Message,
L3.ExecutionTime,
L1.Parameters as InputModel,
L2.Parameters as OutputModel,
L3.Parameters as HttpResponse
from Log L1
inner join Log L2 ON L1.Session = L2.Session
inner join Log L3 ON L1.Session = L3.Session
where L1.Message = 'Call Begin'
and L2.Message = 'Call Response'
and L3.Message = 'Call End'
This would work in your sample.
I have an app that is using push notifications with apples APNS.
Most of the time it works fine, however occasionally (at random it seems, I havent been able to find any verifiable pattern) the messages just dont seem to be getting to the phone.
The messages are being recieved by APNS but just never delivered. However when I reinstall the app or restart the iPhone they seem to arrive.
Im not sure if this is a problem within my app or not, as even when the app is closed (and handling of the notification should rest completely with the Operating System no notification is recieved until a restart/reinstall is done.
The feedback service yields nothing, and NSLogging the received notification within the app also yields nothing (like the notification never makes it to the app)
EDIT:
Some additional information, as nobody seems to know whats going on.
I am using the sandbox server, with the app signed with the developer provisioning profile, so theres no problems there. And the App recieves the notifications initially.
The problem seems to be that when the app doesnt recieve anything when its in the background for about 90s-120s it just stops receiving anything until it is reinstalled.
Even double tapping home and stopping the app that way doesnt allow it to recieve notifications in the app closed state. Which I would have thought would have eliminated problems with the apps coding entirely, since at that point its not even running.
I timed it to see after how long it stops recieving notifications. There are 3 trials here.
==================================Trial 1=====================================
| Notification Number | Time since Last | Total Time | Pass/fail |
| 1 | 6s | 6s | Pass |
| 2 | 30s | 36s | Pass |
| 3 | 60s | 96s | Pass |
| 4 | 120s | 216s | Fail |
==============================================================================
==================================Trial 2=====================================
| Notification Number | Time since Last | Total Time | Pass/fail |
| 1 | 3s | 3s | Pass |
| 2 | 29s | 32s | Pass |
| 3 | 60s | 92s | Pass |
| 4 | 91s | 183s | Fail |
==============================================================================
==================================Trial 3=====================================
| Notification Number | Time since Last | Total Time | Pass/fail |
| 1 | 1s | 1s | Pass |
| 2 | 30s | 61s | Pass |
| 3 | 30s | 91s | Pass |
| 4 | 30s | 121s | Pass |
| 5 | 30s | 151s | Pass |
| 6 | 30s | 181s | Pass |
| 7 | 30s | 211s | Pass |
| 8 | 30s | 241s | Pass |
| 9 | 60s | 301s | Pass |
| 10 | 120s | 421s | Fail |
==============================================================================
Does anyone have any idea what could be going on here.
Another Edit:
Just tested the problem across multiple devices, and its happening on all of them, so its definately not a device issue. The notifications stop coming through even when the app has never been openened. Could the programming within the app effect how the push notifications are received even when its never been open?
It appears this may have been an issue outside of my control, as everything is now working fine, with zero changes.
Going to blame apple or some sort of networking problem somewhere inbetween.