Skip to content

[Question] How to get RequestBody when defined plugins in mysql mode #4477

@ColdFragrance

Description

@ColdFragrance

Question

In ShenYu-2.5.0, I defined a plugin as follow

protected Mono doExecute(final ServerWebExchange exchange, final ShenyuPluginChain chain, final SelectorData selector, final RuleData rule) {
Flux<DataBuffer> fluxMap = exchange.getRequest().getBody();
    fluxMap.subscribe(dataBuffer -> {
    	InputStream inputStream = dataBuffer.asInputStream();
        try {
			byte[] bytes = new byte[0];
			bytes = new byte[inputStream.available()];
			inputStream.read(bytes);
			String body = new String(bytes);
	        log.info("请求body信息 >> {}", body);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if(null != inputStream) {
				try {
					inputStream.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
    });   
    return chain.execute(exchange);
}

And, request command is

curl -X POST http://localhost:9077/flow/one?n=999 -H "Content-Type: application/json" -H "X-Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyTmFtZSI6ImFkbWluIiwiZXhwIjoxNjc4MzI0ODAyfQ.9QjlqXGYpXFXR70w3RFCFJ2dcwbrnrY2gTHyiVyF5io" -d "{"a":"1","b":"2","c":"3"}"

When I use oracle model via changing spring.profiles.active to 'oracle' in application.yaml, it is works.But use mysql model,it cannot enter fluxMap.subscribe(dataBuffer -> {}) fragment.
My Questions:
1.How to get RequestBody?
2.What's the difference between oracle and mysql?

Addtionally,Shenyu-Admin is works when mysql model,but not works when oracle model,such as
image

org.springframework.dao.DuplicateKeyException: ### Error updating database. Cause: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: 违反唯一约束条件 (WORKFLOW_USER.SYS_C0026987) ### The error may exist in class path resource [mappers/operation-record-log-sqlmap.xml] ### The error may involve org.apache.shenyu.admin.mapper.OperationRecordLogMapper.insert-Inline ### The error occurred while setting parameters ### SQL: insert into operation_record_log( id, color, context, operator, operation_time, operation_type) values ( ?, ?, ?, ?, ?, ? ) ### Cause: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: 违反唯一约束条件 (WORKFLOW_USER.SYS_C0026987) ; ORA-00001: 违反唯一约束条件 (WORKFLOW_USER.SYS_C0026987) ; nested exception is java.sql.SQLIntegrityConstraintViolationException: ORA-00001: 违反唯一约束条件 (WORKFLOW_USER.SYS_C0026987)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions