POST data from one page to another - java

I am trying to implement some data flow as follows
______________ _____________ _____________
| myecom.com | submit | myecom.com | add additional | payment.com |
| product.html |------------>| process.php |----------------->| pay.php |
| myform | form data | | data & submit | |
-------------- ------------- -------------
|
______________ |
| myecom.com |<--------------------------------
| receiver.php | success or failure info
--------------
An ecommerce site receive some info from user
Submit the info to an internal processor
The internal processor processes the data
The processed data along with some additional data is submitted to an external processor
The external processor sends back some success/failure report
My goal is to perform step 4 without informing the user what data is being submitted to external processor. In another word, I want to POST some data to the external processor from the internal processor.
FYI, simply cURL will not do as it does not redirect. The page must redirect to payment.com/pay.php. Also, it need to to be PHP specific, any technology like Java, etc. will do. I am considering storing the data in session using cURL and then javascript redirect. But is there any other ways?
Thanks a lot for your time
Khalid

How about doing it like this instead?
______________ _____________ _____________
| myecom.com | (1) submit | myecom.com | (2) add additional | payment.com |
| product.html |------------>| process.php |-------------------->| pay.php |
| myform | form data | | data & submit | |
-------------- ------------- -------------
| ^ |
| | |
(4) redirect | ---------------------------------
| (3) success or failure info
v
______________
| myecom.com |
| receiver.php |
--------------
Explanation: Your internal processor sends the user data plus the additional data to the external processor. Since it's your server that makes the POST request to the external processor, the user never sees the request and thus cannot see the data that is being sent.
I'm not a PHP programmer, but a quick Google query on "PHP post request" revealed these two links, see if they help you:
How do I send a POST request with PHP?
Three Ways to Make a POST Request from PHP

Related

SAP Hybris - DataHub - 400 Bad Request y2ySyncYaaS

I am trying to sync my YaaS configurations from the backoffice.I get a 400 error
`
INFO | jvm 1 | main | 2020/01/20 00:00:09.408 | [m[32mINFO [TaskExecutor-master-544956-Task [8812098257846]] [ProcessChangesTask] Created SyncImpExMediaModel >>>> SyncImpExMediaModel (8897965031454#1) [syncExecutionID: 00006NUA]
INFO | jvm 1 | main | 2020/01/20 00:00:09.708 | [m[32mINFO [TaskExecutor-master-544961-Task [8812098454454]] [DefaultExportService] Export was successful (using cronjob with code=00006NUH)
INFO | jvm 1 | main | 2020/01/20 00:00:09.808 | [m[32mINFO [TaskExecutor-master-544961-Task [8812098454454]] [ProcessChangesTask] Created SyncImpExMediaModel >>>> SyncImpExMediaModel (8897965293598#1) [syncExecutionID: 00006NU9]
INFO | jvm 1 | main | 2020/01/20 00:00:09.909 | [m[32mINFO [TaskExecutor-master-544961-Task [8812098454454]] [ProcessChangesTask] Created SyncImpExMediaModel >>>> SyncImpExMediaModel (8897965359134#1) [syncExecutionID: 00006NU9]
INFO | jvm 1 | main | 2020/01/20 00:00:10.309 | [m[32mINFO [TaskExecutor-master-544969-Task [8812098487222]] [DataHubRequestCreator] Sending request to datahub # http://xx.xx.xx.xx:8080/datahub-webapp/v1/y2ysync/v60 with sync execution id: 00006NU9
INFO | jvm 1 | main | 2020/01/20 00:00:10.309 | [m[1;31mERROR [TaskExecutor-master-544969-Task [8812098487222]] [DataHubRequestTaskRunner] 400 Bad Request
INFO | jvm 1 | main | 2020/01/20 00:00:10.309 | [m org.springframework.web.client.HttpClientErrorException: 400 Bad Request
INFO | jvm 1 | main | 2020/01/20 00:00:10.309 | at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91) ~[spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
INFO | jvm 1 | main | 2020/01/20 00:00:10.309 | at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:667) ~[spring-web-4.3.3.RELEASE.jar:4.3.3.RELEASE]
INFO | jvm 1 | main | 2020/01/20 00:00:10.309 |
`
Here is my datahub config :
`
datahubadapter.datahuboutbound.url=http://xxx.xxx.xxx.xxx:8080/datahub-webapp/v1
y2ysync.datahub.url=http://xxx.xxx.xxx.xxx:8080/datahub-webapp/v1/y2ysync/v60
y2ysync.batch.size=10000
y2ysync.datahub.upload.retries=3
`
Do you have any ideas ?
For anyone running into the same problem, what worked for me is:
Putting the right values (Pool , feed , target system) on the export definition
Setting export url to EMPTY on the export job

Firestore adding 2 documents execution time

Is there any difference between those 2 in terms of execution time?
collectionReference.add(testObject)
.addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
#Override
public void onSuccess(DocumentReference documentReference) {
collectionReference.add(testObject2);
}
})
And
collectionReference.add(testObject);
collectionReference.add(testObject2);
In the first case second adding will be executed after first one is finished, is the same thing happening in second case? Is the second adding queried and is waiting for first to finish, or are they running in parallel?
Yes, there will be a difference between the execution time of these two.
In the first case you're waiting for the first write to be completed on the server, before sending the second write to the server. In a diagram:
Client Server
| |
|---- Send document to write ----->|
| |
| |
|<----- Response from server ------|
|---- Send document to write ----->|
| |
| |
|<----- Response from server ------|
| |
In the second case, the second write is sent to the server right after the first write was sent.
Client Server
| |
|---- Send document to write ----->|
|---- Send document to write ----->|
| |
| |
| |
|<----- Response from server ------|
|<----- Response from server ------|
| |
The difference in performance between these two is the latency of the connection between you and the server.
Note that this is just the theoretical difference, and likely there are many more factors influencing the performance.

python rabbitmqadmin list queues command doesn't obtain messages content although messages exist

I am learning rabbitMq and and now I want to know how to wath queue content.
First of all I want to day that I googled this question and know about command
python rabbitmqadmin list queues
I have written 2 separated applications.
sender:
#Autowired
private AmqpTemplate template;
...
for (int i = 0; i < 100; i++) {
template.convertAndSend("queue1", "message_" + i);
}
receiver:
#RabbitListener(queues = "queue1")
public void listenQueue1(String message, #Header(AmqpHeaders.DELIVERY_TAG) long tag) {
logger.info("Got message:[" + message + "]");
}
If I run these applications together - I see messages on receiver side.
To see messages in the queue I decided to stop receiver and run sender
I run sender
execute python rabbitmqadmin list queues
and see following result:
+-----------------+----------+
| name | messages |
+-----------------+----------+
| query-example-6 | |
| queue1 | |
| queue2 | |
| queue3 | |
| queue4 | |
| queue5 | |
| queue6 | |
| queue7 | |
| queue8 | |
| queue9 | |
+-----------------+----------+
3.Then I run receiver and see logs that receiver accepted messages
Can you clarify reason why I can't see messages in console?
How to see queue messages content.
I am not familiar with rabbitmq.
maybe the message is "unacknowledged"?
e.g. I found my queue has a message:
$ rabbitmqadmin list queues name node messages
+----------------------------+----------------+----------+
| name | node | messages |
+----------------------------+----------------+----------+
| my_queue_name | rabbit#xx-2 | 1 |
but when I run "get" command to show its content, rabbitmq tells me "there's no item"
so, I query it with this command:
$ rabbitmqadmin list queues name node messages messages_ready messages_unacknowledged
+----------------------------+----------------+----------+----------------+-------------------------+
| name | node | messages | messages_ready | messages_unacknowledged |
+----------------------------+----------------+----------+----------------+-------------------------+
| my_queue_name | rabbit#xxxxx-2 | 1 | 0 | 1 |
+----------------------------+----------------+----------+----------------+-------------------------+
I don't know why. just restart the rabbitmq server and everything seems goes fine.

Spring: Initialize multiple connection pools at startup

I want to initialize multiple connection pools at context startup by reading connection parameters from a database table. Basically I want to address following two things
Read connection properties from database not the properties file.
Their are multiple connection pool(rows in db) details.
So my question is How can I iterate over list of rows returned by database in spring-context file and create multiple data-source objects and store them (Lets say in a map) with a unique key?
Databse table structure are somewhat like following:
+--------------+----------------+---------------+
| DBSERVERNAME | DBDRIVERCLASS | DBMINPOOLSIZE |
+--------------+----------------+---------------+
| Server1 | Mysql-Driver | 10 |
| Server2 | Oracle-Driver | 20 |
| Server3 | DB2-Driver | 10 |
+--------------+----------------+---------------+
Let me know if more details are needed. Thanks.

RabbitMQ: is internal delivery (between exchanges) guaranteed?

Assuming I have single host RabbitMQ server and settings like below:
.--------------.
.->| EX fanout |
.-----------.--' | "monitoring" |
| EX fanout | '--------------' .----.
| "common" |--. .-----------. .->| Q1 |
'-----------' '->| EX direct |--q1--' '----'
| "queues" |--q2--. .----.
'-----------' '->| Q2 |
'----'
When I send message to exchange "common" with routing key "q1" - is it guaranteed that message reach Q1 queue?
I want to make sure such message wont get stuck somewhere between exchanges or between exchange and queue.

Categories