Skip to content

Commit

Permalink
SysDaoMessageService增加广播消息处理
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Jan 23, 2025
1 parent f8ba93c commit 8ef6e28
Show file tree
Hide file tree
Showing 19 changed files with 417 additions and 70 deletions.
6 changes: 6 additions & 0 deletions nop-api-core/src/main/java/io/nop/api/core/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ public interface ApiConstants extends FilterBeanConstants {

String HEADER_SVC_NAME = "nop-svc-name";

String HEADER_TOPIC = "nop-topic";

String HEADER_EVENT_TIME = "nop-event-time";

String HEADER_PROCESS_TIME = "nop-process-time";

/**
* 业务对象上执行的方法
*/
Expand Down
25 changes: 25 additions & 0 deletions nop-api-core/src/main/java/io/nop/api/core/util/ApiHeaders.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.nop.api.core.convert.ConvertHelper;
import io.nop.api.core.exceptions.NopException;

import java.sql.Timestamp;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -316,6 +317,30 @@ public static void setSvcName(ApiMessage message, String value) {
message.setHeader(ApiConstants.HEADER_SVC_NAME, value);
}

public static String getTopic(ApiMessage message) {
return getStringHeader(message.getHeaders(), ApiConstants.HEADER_TOPIC);
}

public static void setTopic(ApiMessage message, String value) {
message.setHeader(ApiConstants.HEADER_TOPIC, value);
}

public static Timestamp getEventTime(ApiMessage message) {
return ConvertHelper.toTimestamp(getHeader(message.getHeaders(), ApiConstants.HEADER_EVENT_TIME));
}

public static void setEventTime(ApiMessage message, Timestamp value) {
message.setHeader(ApiConstants.HEADER_EVENT_TIME, ConvertHelper.toLong(value));
}

public static Timestamp getProcessTime(ApiMessage message) {
return ConvertHelper.toTimestamp(getHeader(message.getHeaders(), ApiConstants.HEADER_PROCESS_TIME));
}

public static void setProcessTime(ApiMessage message, Timestamp value) {
message.setHeader(ApiConstants.HEADER_PROCESS_TIME, ConvertHelper.toLong(value));
}

public static String getSvcAction(ApiMessage message) {
return getStringHeader(message.getHeaders(), ApiConstants.HEADER_SVC_ACTION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public enum StdSqlType implements ISqlDataType {
// ROW(PrecScale.NO_NO, false, Types.STRUCT, null),
OTHER(false, false, Types.OTHER, StdDataType.ANY),

JSON(false, false, Types.JAVA_OBJECT, StdDataType.ANY),
JSON(false, false, Types.VARCHAR, StdDataType.STRING),

ANY(false, false, Types.JAVA_OBJECT, StdDataType.ANY),
// CURSOR(PrecScale.NO_NO, false, ExtraSqlTypes.REF_CURSOR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2864,6 +2864,16 @@
"methods": [],
"name": "io.nop.commons.concurrent.executor.ThreadPoolConfig"
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allPublicConstructors": true,
"allPublicFields": true,
"allPublicMethods": true,
"fields": [],
"methods": [],
"name": "io.nop.commons.functional.ChainedAsyncFunctionInvoker"
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
Expand Down Expand Up @@ -6309,6 +6319,26 @@
"methods": [],
"name": "io.nop.graphql.core.IBizModelImpl"
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allPublicConstructors": true,
"allPublicFields": true,
"allPublicMethods": true,
"fields": [],
"methods": [],
"name": "io.nop.graphql.core.audit.DefaultGraphQLAuditer"
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allPublicConstructors": true,
"allPublicFields": true,
"allPublicMethods": true,
"fields": [],
"methods": [],
"name": "io.nop.graphql.core.audit.GraphQLAuditOperationInvoker"
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
Expand Down Expand Up @@ -6366,6 +6396,16 @@
],
"name": "io.nop.graphql.core.engine.GraphQLEngine"
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allPublicConstructors": true,
"allPublicFields": true,
"allPublicMethods": true,
"fields": [],
"methods": [],
"name": "io.nop.graphql.core.engine.GraphQLTransactionOperationInvoker"
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
Expand Down Expand Up @@ -9671,6 +9711,16 @@
"methods": [],
"name": "io.nop.sys.dao.entity.NopSysSequence"
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allPublicConstructors": true,
"allPublicFields": true,
"allPublicMethods": true,
"fields": [],
"methods": [],
"name": "io.nop.sys.dao.entity.NopSysServiceInstance"
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
Expand Down Expand Up @@ -9856,6 +9906,21 @@
],
"name": "io.nop.sys.dao.entity._gen._NopSysSequence"
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allPublicConstructors": true,
"allPublicFields": true,
"allPublicMethods": true,
"fields": [],
"methods": [
{
"name": "newInstance",
"parameterTypes": []
}
],
"name": "io.nop.sys.dao.entity._gen._NopSysServiceInstance"
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
Expand Down Expand Up @@ -10076,6 +10141,16 @@
"methods": [],
"name": "io.nop.sys.service.entity.NopSysSequenceBizModel"
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allPublicConstructors": true,
"allPublicFields": true,
"allPublicMethods": true,
"fields": [],
"methods": [],
"name": "io.nop.sys.service.entity.NopSysServiceInstanceBizModel"
},
{
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
Expand Down Expand Up @@ -10504,7 +10579,14 @@
"allPublicFields": true,
"allPublicMethods": true,
"fields": [],
"methods": [],
"methods": [
{
"name": "transformPermissions",
"parameterTypes": [
"java.lang.Object"
]
}
],
"name": "io.nop.web.page.PageProvider"
},
{
Expand Down
10 changes: 10 additions & 0 deletions nop-demo/nop-quarkus-demo/src/main/resources/nop-vfs-index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@
/nop/core/xlib/biz!when.xlib
/nop/core/xlib/biz-gen.xlib
/nop/core/xlib/biz.xlib
/nop/core/xlib/dsl-gen.xlib
/nop/core/xlib/file.xlib
/nop/core/xlib/filter.xlib
/nop/core/xlib/meta-gen.xlib
Expand Down Expand Up @@ -854,6 +855,10 @@
/nop/sys/model/NopSysSequence/NopSysSequence.xmeta
/nop/sys/model/NopSysSequence/_NopSysSequence.xbiz
/nop/sys/model/NopSysSequence/_NopSysSequence.xmeta
/nop/sys/model/NopSysServiceInstance/NopSysServiceInstance.xbiz
/nop/sys/model/NopSysServiceInstance/NopSysServiceInstance.xmeta
/nop/sys/model/NopSysServiceInstance/_NopSysServiceInstance.xbiz
/nop/sys/model/NopSysServiceInstance/_NopSysServiceInstance.xmeta
/nop/sys/model/NopSysUserVariable/NopSysUserVariable.xbiz
/nop/sys/model/NopSysUserVariable/NopSysUserVariable.xmeta
/nop/sys/model/NopSysUserVariable/_NopSysUserVariable.xbiz
Expand Down Expand Up @@ -929,6 +934,11 @@
/nop/sys/pages/NopSysSequence/_gen/_NopSysSequence.view.xml
/nop/sys/pages/NopSysSequence/main.page.yaml
/nop/sys/pages/NopSysSequence/picker.page.yaml
/nop/sys/pages/NopSysServiceInstance/NopSysServiceInstance.lib.xjs
/nop/sys/pages/NopSysServiceInstance/NopSysServiceInstance.view.xml
/nop/sys/pages/NopSysServiceInstance/_gen/_NopSysServiceInstance.view.xml
/nop/sys/pages/NopSysServiceInstance/main.page.yaml
/nop/sys/pages/NopSysServiceInstance/picker.page.yaml
/nop/sys/pages/NopSysUserVariable/NopSysUserVariable.lib.js
/nop/sys/pages/NopSysUserVariable/NopSysUserVariable.lib.xjs
/nop/sys/pages/NopSysUserVariable/NopSysUserVariable.view.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public void testGen() {
codeGen.reloadModel();
});

// bizObjectManager.getBizObject("MyDynEntity_one");

ormTemplate.runInSession(() -> {

IEntityDao<NopDynEntity> dao = daoProvider.dao("MyDynEntity");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8" ?>

<lib x:schema="/nop/schema/xlib.xdef"
xmlns:x="/nop/schema/xdsl.xdef" xmlns:xdsl="xdsl" xmlns:xpl="xpl" xmlns:c="c" xmlns:ui="ui">

<tags>
<DefaultMetaPostExtends outputMode="node">
<attr name="_dsl_root" implicit="true"/>

<source>
<c:script>
logInfo("DefaultM2222___{}", _dsl_root)
</c:script>
<thisLib:GenDictLabelFields/>
</source>
</DefaultMetaPostExtends>


<GenDictLabelFields outputMode="node">
<attr name="_dsl_root" implicit="true"/>

<source>
<meta>
<props>
<c:for var="prop" items="${_dsl_root.childByTag('props').children}">
<c:script><![CDATA[
let name = prop.attrText('name');
if(name.endsWith("_label"))
continue;
let dict = prop.childAttr('schema','dict');
if(!dict)
continue;
]]></c:script>

<prop name="${name}" graphql:labelProp="${name}_label"
xpl:if="!prop.hasAttr('graphql:labelProp')">
</prop>

<prop name="${name}_label" displayName="${prop.getAttr('displayName')}" internal="true"
graphql:dictName="${dict}" graphql:dictValueProp="${name}">
<schema type="String"/>
</prop>
</c:for>
</props>
</meta>
</source>
</GenDictLabelFields>
</tags>
</lib>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<meta x:schema="/nop/schema/xmeta.xdef" xmlns:x="/nop/schema/xdsl.xdef" x:dump="true">
<entityName>${entityModel.name}</entityName>

<primaryKey>${_.join(entityModel.pkColumnNames,',')}</primaryKey>
<c:script>const dispCol = entityModel.getColumnByTag('disp')</c:script>
<displayProp xpl:if="dispCol">${dispCol.name}</displayProp>

<c:print>
<x:gen-extends111>
<meta-reload:DefaultMetaGenExtends xpl:lib="/nop/core/xlib/meta-reload.xlib"/>
</x:gen-extends111>

<x:post-extends>
<meta-reload:DefaultMetaPostExtends xpl:lib="/nop/core/xlib/meta-reload.xlib"/>
</x:post-extends>
</c:print>

<c:import from="/nop/codegen/xlib/meta-gen.xlib"/>

<props>
<c:for var="col" items="${entityModel.columns}">
<prop name="${col.name}___11111" displayName="${col.displayName}" propId="${col.propId}"/>
</c:for>
</props>
<meta-gen:GenMetaExt entityModel="${entityModel}" xpl:lib="/nop/codegen/xlib/meta-gen.xlib"/>
</meta>
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@

public interface MessageCoreConstants {
String BEAN_LOCAL_MESSAGE_SERVICE = "nopLocalMessageService";

String TOPIC_PREFIX_BROADCAST = "bro-";
String TOPIC_PREFIX_BATCH = "bat-";
String TOPIC_PREFIX_REPLY = "reply-";
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
import io.nop.api.core.message.MessageSubscribeOptions;
import io.nop.api.core.util.FutureHelper;
import io.nop.api.core.util.Guard;
import io.nop.message.core.MessageCoreConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
Expand Down Expand Up @@ -117,6 +120,26 @@ private Subscription findSubscription(List<Subscription> subscriptions, IMessage
return null;
}

public Set<String> getBroadcastTopics() {
Set<String> ret = new TreeSet<>();
for (String topic : consumers.keySet()) {
if (topic.startsWith(MessageCoreConstants.TOPIC_PREFIX_BROADCAST)) {
ret.add(topic);
}
}
return ret;
}

public Set<String> getNonBroadcastTopics() {
Set<String> ret = new TreeSet<>();
for (String topic : consumers.keySet()) {
if (!topic.startsWith(MessageCoreConstants.TOPIC_PREFIX_BROADCAST)) {
ret.add(topic);
}
}
return ret;
}

@Override
public IMessageSubscription subscribe(String topic, IMessageConsumer listener, MessageSubscribeOptions options) {
Guard.notEmpty(topic, "topic");
Expand Down
Binary file modified nop-sys/model/nop-sys.orm.xlsx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@ public interface NopSysDaoConstants extends _NopSysDaoConstants {

String RESOURCE_GROUP_DEFAULT = "default";

String TOPIC_PREFIX_BROADCAST = "bro-";
String TOPIC_PREFIX_BATCH = "bat-";
String TOPIC_PREFIX_REPLY = "reply-";

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@


@BizObjName("NopSysEvent")
public class NopSysEvent extends _NopSysEvent{
public class NopSysEvent extends _NopSysEvent {

public NopSysEvent() {

}
}
Loading

0 comments on commit 8ef6e28

Please sign in to comment.