Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-enterprise-base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
base_platform_enterprise
gic-enterprise-base
Commits
3a6fdb37
Commit
3a6fdb37
authored
Oct 31, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dubbo泛化回调工具
parent
98d62223
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
0 deletions
+48
-0
AsyncCallbackUtils.java
...ain/java/com/gic/enterprise/utils/AsyncCallbackUtils.java
+48
-0
No files found.
gic-enterprise-base-api/src/main/java/com/gic/enterprise/utils/AsyncCallbackUtils.java
0 → 100644
View file @
3a6fdb37
package
com
.
gic
.
enterprise
.
utils
;
import
org.apache.dubbo.config.ReferenceConfig
;
import
org.apache.dubbo.config.RegistryConfig
;
import
org.apache.dubbo.config.utils.ReferenceConfigCache
;
import
org.apache.dubbo.rpc.service.GenericService
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
com.alibaba.fastjson.JSONObject
;
/**
* 异步回调工具
* @ClassName: AsyncCallbackUtils
* @Description:
* @author guojuxing
* @date 2019/10/31 3:41 PM
*/
public
class
AsyncCallbackUtils
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
AsyncCallbackUtils
.
class
);
/**
* 回调
* @Title: callBack
* @Description:
* @author guojuxing
* @param obj 需要传递的参数对象
* @param interfaceUrl 接口路径 例如com.gic.open.api.service.market.PayCallbackApiService
* @param method 方法名称 payCallbackTransfer
* @return void
*/
public
static
void
callBack
(
Object
obj
,
String
interfaceUrl
,
String
method
)
{
logger
.
info
(
"回调:{},接口路径:{},接口方法名称:{}"
,
JSONObject
.
toJSONString
(
obj
),
interfaceUrl
,
method
);
RegistryConfig
registry
=
new
RegistryConfig
();
registry
.
setAddress
(
"zookeeper://10.105.220.75:2199"
);
registry
.
setCheck
(
false
);
ReferenceConfig
<
GenericService
>
reference
=
new
ReferenceConfig
<>();
reference
.
setInterface
(
interfaceUrl
);
reference
.
setRegistry
(
registry
);
reference
.
setGeneric
(
true
);
ReferenceConfigCache
cache
=
ReferenceConfigCache
.
getCache
();
GenericService
genericService
=
cache
.
get
(
reference
);
// 注意! Cache会持有ReferenceConfig,不要在外部再调用ReferenceConfig的destroy方法,导致Cache内的ReferenceConfig失效!
genericService
.
$invoke
(
method
,
new
String
[]{
String
.
class
.
getName
()},
new
String
[]{
JSONObject
.
toJSONString
(
obj
)});
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment